1/07/2015

C++ Functions : Talks to you




# What is a Function?
    # A function, so i have a list of C++ statements and i want to give them a name and whenever i am going to call that name those statements should be executed.
    # This is why, functions are re-usable block of code that can optionally take arguments.
    ## Does function arguments necessary?
        # No? they are optional, but they make functions more dynamic and powerful. 
   
# Why we need Functions?
    # When you write code then you might feel that THIS block of code of these number of statements are being repeated.
    # So now you are thinking that, Is there any technique that can help you, Because you are lazy ( or smart ) and you do not want to write those statements again and again.
    # Ok, I am going to pack these number of statements and let me think about a name that can characterize its property, means what it does and when anybody can call them.

# Types of functions in C++?
    # Function that return nothing.
    # Function that can return something.
    # Function that can return multiple values.
    # Recursive Functions ( sometimes i have to call myself. )


    # Function with some parameters.
    # Function with multiple parameters.

    # Over-loaded Functions ( Same name for function but different Signature)


    # Inline functions ( matters for compiler. )
    # Function with parameters values ( we got values for these parameters )
    # Function with parameters and some/all of them have some default value.


    # Function with references ( so they trust us, we got address for these parameters, now i can directly go there, If you do not mind we can also change the contents of that addresses that you give us. )





    # Function that return Memory Address ( Sorry, I can not return you any value but i can tell you where i put my results. )
    # Function that will promise you that you can trust them and give them references of parameters values, they will never try to change their contents.






# What is a C++ Function Template?
    # A block of C++ Code that will be rendered at compile time with supplied template parameters.
    # Functions with generic types, known as function templates.







# How C++ Function is different from C++ Function?
    # Function can return some value.
    # Template can not, this will be rendered with supplied template arguments.



# References :-
http://www.cplusplus.com/doc/

No comments :