一个小程序解释指针变量的作用:
#include<iostream> #include"cww.h" void cloud(int *); using namespace std; int main(){ int n = 1; int *p = &n; cloud(p); cout<<"&n = "<<(&n)<<", n = "<<n<<endl; system("PAUSE"); return 0; } void cloud(int *p) { *p = 13; cout<<" p = "<<p<<", *p = "<<(*p)<<endl; }
输出:
p = 003FFEB0, *p = 13 &n = 003FFEB0, n = 13