I wouldn't agree to Nikolai's answer. In C++ there are two ways of passing the arguments.
f(Type Name)
is your case, where Type is int*
and Name is p
(note that int *p
actually means int* p
). In this case, inside your function Name is a copy of the object that you pass to the function.
The second way
f(Type & Name)
does not make a copy, but creates an alias to the object instead, so that you can modify the original object.
In your case, the object is the pointer of a type int*
. As you pass it using the first syntax, you get a copy of it which you modify and the original pointer is left unchanged. If you want to change the original pointer, then you should pass it by reference, so for Type=int*
and Name=p
you'd get
f(int*& p)