C++创建引用变量

#include
using namespace std;
int main()
{
 int rats = 101;
 int& rodents = rats;
 cout << "rats = " << rats;
 cout << ",rodents = " << rodents << endl;
 cout << "rats address = " << &rats;
 cout << ",rodents address = " << &rodents << endl;
 int bunnies = 50;
 rodents = bunnies;
 cout << "bunnies = " << bunnies;
 cout << ",rodents = " << rodents;
 cout << ",rats = " << rats << endl;
 cout << "bunnies address = " << &bunnies;
 cout << ",rodents address = " << &rodents;
 return 0;
}

在这里插入图片描述

你可能感兴趣的:(C++,引用变量)