At some moment we may need to pass an array to a function as a parameter. In C++ it is not possible to pass a complete block of memory by value as a parameter to a function, but we are allowed to pass its address. In practice this has almost the same effect and it is a much faster and more efficient operation.

In order to accept arrays as parameters the only thing that we have to do when declaring the function is to specify in its parameters the element type of the array, an identifier and a pair of void brackets []. For example, the following function:


void procedure (int arg[])


accepts a parameter of type "array of int" called arg. In order to pass to this function an array declared as:


int myarray [40];


it would be enough to write a call like this:


procedure (myarray);

Designed By Blogger Templates | Templatelib & Distributed By Blogspot Templates