Call by reference, C/C++ Programming

Call by reference:

Arguments to a function can be passed in two way; one by call by value and other by call

by reference.  Call by value is passed either through a constant or variable.  The call by reference is passed through address operator (&).  In C the function definition argument must be declared as pointer variable to pass by reference, where as in C++ the call by reference can be used without declaring the function arguments as pointer variables.  But in C++ both pointer argument method and without pointer argument can be adopted.


void f_ref(int &a, int &b); // void f_ref(int, int) is wrong for reference variable;

void main( )

{int a, b;

f_ref(a, b); // The value a is 10 and b is 20.




void f_ref(int &x, int &y)

{x =10;



Posted Date: 9/20/2012 7:45:33 AM | Location : United States

Related Discussions:- Call by reference, Assignment Help, Ask Question on Call by reference, Get Answer, Expert's Help, Call by reference Discussions

Write discussion on Call by reference
Your posts are moderated
Related Questions
Object Conversions Just like initialization, conversions are also done automatically when an object of a derived class is assigned to an object of the base class. Though, the c

How much does it cost to complete a C++ assignment that is 80% finished??

Add words in Dictionary: void Dictionary::add( Object& objectToAdd ) {     if( !objectToAdd.isAssociation() )         ClassLib_error( __ENOTASSOC );     else

The procedure +, * and list take arbitrary numbers of arguments. One way to define such a procedure is to use define with dotted-tail notation. In a procedure definition, a paramet

Define some Important Point for bit fields with structures? Only n lower bits will be assigned to an n bit number thus type cannot take values larger than 15 (4 bits long)

a program to accept average, if average is 75 to 85 print it out else bypass using counter. enter and process 5 records

depth description of the inside and outside typecasting