Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Functions in c++
1. Programming with c++
By
S.Thanga rathinam(181619)
M.Vivek mani(181620)
II Bsc.mathematics(CA)
SBK college ,Aruppukottai
To
K.Padma Priya M.Sc(CS),M.Phill.
Assistant Professor
Dept of Mathematics(CA)
SBK college,Aruppukottai
2. Functions in c++
The main function
Function prototyping
Call by reference
Return by reference
Inline function
3. The main function:
C does not specify any return type for the main()
function which is the starting point for the execution of a
program. The definition of main() would look this
Eg:
main()
{
//main program statements
}
This is perfectly vaild because the main() inc does not return
any value.
4. The main() returns a value of type int to the operating system
.
Eg :
int main();
int main(int argc,char*argv[]);
The functions that have a return value should use the
return statement for termination.
The main() function in c++ is
int main()
{
………….
………….
return 0;
}
5. Function prototyping:
Function prototyping is one of the majar improvements
added to c++ functions.
Function prototype is a decleration statement in the
calling program and is of the following form:
type function-name (argument-list);
The argument-list contains the types and names of
arguments that must be passed to be the function.
6. Eg:
float volume(int x, float y, float z);
we can also declare a function with an empty argument
list.
Void display( );
7. Call by reference:
In traditional c a function call passes arguments
by value. The called function reates a new set of variables and
copies the values of arguments into them.the function does
not have access to the actual variables in the calling program
and only work on the copies of values.
The reference variables inc++ permits us to pass
parameters to the function by reference .
8. void swape (int a, int b)
{
int t=a;
a=b;
b=t;
}
If m and n are two integer variables then function call
swap (m,n);
9. Return by reference:
A function can also returns a reference.
int & max (int &x, int &y)
{
if (x>y)
return x;
else
return y;
}
10. The return type of max() is int & the function returns
reference x or y .Then function call such as max(a,b) will yeild
a reference to either a or b dependingon their values .This
means that this function call can appear on the left hand side
of their assignment statement.
max (a,b) = -1;
Is legal and assigns -1 to a if it is larger , otherwise -1 to
b.
11. Inline functions:
An inline function is a function that is expended in line
when it is invoked.this inline fuctions are
inline function-header
{
function body
}
Eg:
inline double cube(double a)
{
return (a*a*a*);
}
12. It is easy to make a funtion inline.
Some of the situations where inline expansion may not work
are:
For function returningvalues if a loop,a switch, or a goto
exists.
For a function not returning values if a return statement
exists.
If functions contains static variables.
If inline functions are recursive