previous | start | next

Syntax of Passing Arguments to a Function

There is NO difference in the syntax of calling a function if its parameters are call by value or call by reference.

The compiler has to see the declaration of the function being called to determine how to pass the arguments.

The programmer writes the same sytnax for the call in either case.

Are arguments a and b passed by value or reference by the following code? You can't tell unless you see the declaration of the swap function.

int main()
{
   int a = 5, b = 10;

   swap(a,b);

   cout << a << b << endl;

   return 0;
}


previous | start | next