void setter ( int a[])
{
}
void setter( int *pToInt)
{
}
The above function are equivalent. The compiler finds them identicall and throws an error.
void setter( int a)
{
}
void setter( int &refToInt)
{
}
The above functions are both accepted by the compiler but an ambigous call is thrown depending on calling:
Example:
void main(void)
{
int b=10;
int &refToInt = b;
setter(b);
setter(refToInt); // here is ambigous
}
void main(void)
{
int b=10;
int &refToInt = b;
setter(refToInt); // again here is ambiguos call!!
}
The solution for your problem:
void setter (int *, int dim)
{
}
or
void setter(int a[], int dim)
{
}
As you can see, you have to pass the dimension of the array.
To understand more, you can read that:
void main (void)
{
int a[10];
int *p1ToInt = a;
int *p2ToInt = &a[0]; // the same as p1ToInt;
int & refToInt = a[0]; // reference to the first element
int & ref2ToInt = a[1]; // reference to the 2nd element
cout<<*a<<endl; // out the a[0]
cout<<*(a+1)<<endl; // out the a[1]
cout<<*p1ToInt<<endl; // out a[0]
cout<<*(p1ToInt + 1) <<endl: // out a[1]
cout<<*p2ToInt<<endl; // out a[0]
cout<<*(p2ToInt +1 )<<endl; // out a[1]
cout<<refToInt<<endl; // out a[0]
cout<<ref2ToInt<<endl;// out a[1]
setter(a,10);
{