首页 > 其他 > 详细

自考新教材--p42

时间:2019-12-02 16:13:07      阅读:87      评论:0      收藏:0      [点我收藏+]

源程序:

#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;

}

 运行结果:

技术分享图片

 

自考新教材--p42

原文:https://www.cnblogs.com/duanqibo/p/11970663.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!