自考新教材--p42

源程序:

#include <iostream>

using namespace std;

int oneX = 10;

int oneY = 20;

int &refValue(int &x)

{

return x;

}

 

int main()

{

refValue(oneX) = 30;//返回值是引用,可以作为左值

cout << "oneX=" << oneX << endl;

refValue(oneY) = 40;//返回值是引用的函数调用表达式,可以作为左值使用

cout << "oneY=" << oneY << endl;

system("pause");

return 0;

}

 运行结果:

 

posted @ 2019-12-02 15:06  bobo哥  阅读(126)  评论(0编辑  收藏  举报