在 C++ 中,一旦定义了引用变量来引用特定变量,它可以引用任何其他变量吗?
我用于测试的代码如下:
int r1 =1001;
int r2 =10023;
int &r3 = r1;
r3 = r2;
r3 = 999;
r3 = 555;
int r4 = 11;
r3 = r4;
r3 = 10177;
cout<<r3<<endl;
cout<<r1<<endl;
cout<<r2<<endl;
cout<<r4<<endl;
输出:
10177
10177
10023
11