Can a pointer be passed by reference? If not, explain why not. If so, briefly describe an example in which passing a pointer by reference is necessary for correct operation. A pointer can be passed either by value or by reference. In either case, it is important to make sure the pointer holds the address of a variable whose lifetime is not about to end (e.g., a local stack variable whose scope is about to end).

When several functions share the storage for a dynamically resizeable object by sharing its address, that address must be passed and received by reference, so that if one module reallocates it, everyone knows where the new version of the object is stored. See the extended example on searching a collection of files example of passing a pointer by reference. In that example, a dynamically allocated array is shared by several functions, any of which may recycle and reallocate it.