Remember that, like any other variable, a pointer itself has an address in memory. When you pass a pointer to a function, a copy of it is made. This copy obviously has a different address than the original. That's why you can do:
Code:
void print(char * s)
{
while(*s != 0)
{
cout << *(s++);
}
cout << endl;
}
The original pointer is unaffected.
Now let's say you wanted to write a function in C that increments a pointer. You would have to do:
Code:
void inc(char ** p)
{
*(p++);
}
With C++, it's simply more readable (and less typing) to use:
Code:
void inc(char * & p)
{
p++;
}