Is it possible to pass a pointer in C++ by reference without just using a double pointer?
I have some code that should work but the refrence portion of it does not seem to be working.
Here is a function similar to what i want to do without all the details.
Code:
void foo(int *&a)
{
int* b=new int[10];
//loop some number of times
//Do some copy operation from b to a
swap(a,b);
delete[] b;
}
When this code exits a should contain the values, unfortunatly right now this is only true if the loop executes an even number of times.