A pointer holds the address of whatever it is pointing to. For example, say the address of an int is 1234, the pointer would hold the value 1234.
When you pass a pointer to a function, it's the same as passing any other variable. That is, it'll create a copy of that point and work on that within the function. You're merely passing a value that holds an address, not passing the address itself.
Like any other variable, you can pass the address of a pointer (see following examples) . I think, however, you'd just be better off returning a pointer as above.
Hello there, what you are not actually passing by reference . Instead try this :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <iostream>
usingnamespace std;
void test(int *ip)
{
*ip = 5;
}
int main()
{
int *ip;
test(ip);
cout<<" IP points to address location : "<<ip;
cout<<"\n Value that IP points to : "<<*ip;
return 0;
} // end of main()