Having an array:
int a = { 1 ,2 , 3}
I can pass a pointer to a function in order to modify it.
int modify( int *a ){
a[0] = 10;
}
But why can't I pass a reference to int to modify it? e.g
int modify( int &a ){
a[0] = 10;
}
How does compiler manipulate with a reference? By using pointers, we pass the memory (in this case, the first element of the array ). But what happens with a reference? Why, for example, does this work?
vector<int > a
void mod( vector<int> & a ){
a[0] = 10;
//a.push_back(10)
}