引用

 1 #include <iostream>
 2 using namespace std;
 3 
 4 int  main()
 5 {
 6     int rats=101;
 7     int &rodents=rats;  //&为引用
 8     cout<<"rats="<<rats;
 9     cout<<",rodents"<<endl;
10     rodents++;
11     cout<<"rats="<<rats;
12     cout<<",rodents"<<rodents<<endl;
13     cout<<"rats address="<<&rats;
14     cout<<",rodents address="<<&rodents<<endl;
15     getchar();
16     return 0;
17 }

posted @ 2018-07-30 16:00  小雨滴答  阅读(125)  评论(0编辑  收藏  举报