Intermediate Business Programming with C++

In a previous lecture the three methods of passing arguments to a function were discussed. One of those was passing by pointers. In order for passing by pointer to be a viable approach, the pointer argument must contain the address of a variable. What is then passed by value is the address of this variable. This method of argument passing can be very helpful especially when the variable whose address is passed occupies a large amount of memory.

When pointers are used as arguments of functions, the functional prototype and definition must contain the pointer operator as in the following example:

void swap(int*, int* );

While the pointer operator appears both in the prototype and the definition of the functions it does not appear in the call. See BYPOINTER.CPP.

Passing by a pointer is different from passing by reference in that

Passing by a pointer is different from passing by value because it permits:

Категории