Your a
is a temporary object in fun()
. I fyou want fun()
to change the pointer to a
you’ll need to take the pointer as reference:
int fun(int*& a) {
a = fun2();
}
Note that this interface is probably severely broken.
solved I lose pointer or an address? It acts like never happen [closed]