void byReference(int (&p)[3]){
int q[3] = {8, 9, 10};
p = q;
}
I want to write function where i can reassign the p with new array. I am not sure if we can do that.
My goal : i want to change the original array, like we do swapping of two number by call-by reference.
Edit:
my working solution :
void byReference(int*& p){
int* q = new int[2];
q[0] = 8;
q[1] = 9;
p = q;
}
int main(){
int *x = new int[2];
x[0] = 1;
x[1] = 2;
byReference(x);
return 0;
}