FUNCTION IN C++ PART-2
Now we are going continue with FUNCTION IN C++ PART-2 with more explanations regarding Function In C++........lessen carefully...
Function Definition:
The first line is called function declarator and is followed by function body.The block followed by function declarator is called as function definition.
Function Call:
Function gets activated only when a call to function is invoked.A function must be called by its name, followed by argument list enclosed in parenthesis and terminated by semi colon.
Arguments:
Actual Arguments:
The arguments declared in the caller function and given in the function call are called as actual arguments.
Formal Arguments:
The arguments declared in the function declarator are known as formal arguments.
Return Statement:
- The return statement is used to return values to the caller function.
- The return statement returns only one value at a time.
Passing The Arguments:
- Call by value (pass by value)
- Call by address (pass by address)
- Instead of passing values, addresses are passed.
- Function operates on address rather than values.
- Formal arguments are pointers to the actual arguments.
- Changes made in the arguments are permanent.
- Call by reference (pass by reference)
Inline Function:
The c++ provides a mechanism called inline function. When a function is declared as inline, the compiler copies the code of the function in the calling function. i.e. function body is inserted in place of function call during compilation.The inline function is mostly useful when calling function is small. The inline mechanism increases execution performance in terms of speed. The program using the inline functions needs more memory space since the inline functions are copied at every point where the function is invoked.
So thats all about FUNCTIONS IN C++ basics you need to know about.....enjoy reading....
Thankyou,
Rajkumar