Is it possible to pass an array by reference to a function?
Like so...
Code:
void clearboard(int& sqr[])
{
for (int i=1; i<11; i++)
sqr[i] = 'X';
}
void board(int& sqr[])
{
cout << sqr[1] << " | " << sqr[2] << " | " << sqr[3]
<< sqr[4] << " | " << sqr[5] << " | " << sqr[6]
<< sqr[7] << " | " << sqr[8] << " | " << sqr[9];
}
int main(int argc, char *argv[])
{
int sqr[10];
clearboard(sqr);
board(sqr);
system("PAUSE");
return 0;
}
For some reason it wont let me compile it...
declaration of `sqr' as array of references
In function `void clearboard()':
`sqr' undeclared (first use this function)
(Each undeclared identifier is reported only once for each function it appears in.)
At global scope: