previous | start | next

How to Specify the Calling Method: Value or Reference

The default calling method is call by value.

     void swap(int x, int y);

Here arguments will be passed to x and y by value.

To specify call by reference place an & (an ampersand) after the parameter type in the function declaration (and definition).

     void swap(int& x, int& y);


previous | start | next