源程序:
#include <iostream>
using namespace std;
int main()
{
int oneInt = 1;
int &ref = oneInt;
ref = 2;
cout << "oneInt=" << oneInt << "," << "ref=" << ref << endl;
int *p = &ref;
*p = 3;
cout << "ref=" << "," << "p的地址:" << p << ",p的值:" << *p << endl;
system("pause");
return 1;
}
运行结果: