Thursday, July 23, 2009

How to Pass Array by Reference?

Receiving arrays by reference have special syntax. The arrayname and & symbol should be enclosed in parenthesis. And you should specify the size of array. Have a look at the following code snippet.

// Receive Array by reference.
void GetArray( int (&Array) [10] )
{
}

// Test array by reference.
void CRabbitDlgDlg::TestArray()
{
// Pass array by reference.
int Array[10] = { 0 };
GetArray( Array );
}

0 comments:

  © Free Blogger Templates Blogger Theme II by Ourblogtemplates.com 2008

Back to TOP