int m_value = 1;void func (int *p) { p = &m_value;} int main (int argc, char *argv[]) { int n = 2; int *PN = &n; cout << *pn << Endl; Func (PN); cout << *PN <<endl; return 0;}
Look at the output.
2
2
-------actually the above examples, see 100 times, I personally feel, also do not see the actual meaning
#include <stdio.h>
#include <malloc.h>
#include <string.h>
void Allocate (char* p,int size) {
printf ("\n%x", &p);
printf ("\n%x", p);
p= (char*) malloc (size);
}
void free (char* p) {
Free (p);
}
void Main ()
{
Char *str=null;
printf ("\n%x", &str);
printf ("\n%x", str);
Allocate (str,100);
strcpy (str, "Hello world!");
printf ("\n%s", str);
Free (str);
printf ("\nstr=%s", str);
}
------above Such a mistake case, have the practical teaching significance!!!
Http://www.cnblogs.com/li-peng/p/4116349.html
http://blog.csdn.net/whzhaochao/article/details/12891329----Classics, speak with facts
Pass-through pointer reference----function/method parameter passed by C + + language parameter