当前位置:网站首页>10 let operator= return a reference to *this
10 let operator= return a reference to *this
2022-07-26 10:41:00 【JeffyGao】
Clause -10 Make operator= Return to one reference to *this
- Make the assignment (saaignment) The operator returns a reference to *this.
Constants have the following assignment chain form :
int x, y, z;
x = y = z = 15;
// x = ( y = (z = 15) )
// 15 First assigned to z, Then the result ( Updated z) Then assigned to y, Similarly, assign to x.
In order to achieve “ Chain assignment ”, The assignment operator must return a reference Point to the left argument of the operator . stay copy assignment Operator returns *this that will do :
class widget {
public:
……
widget& operator= ( const widget& rhs ) {
……
return *this;
}
……
};
The same applies to +=、-+、*=
边栏推荐
- oracle 启动不了 tnslistener服务启动不了
- MLX90640 红外热成像仪测温传感器模块开发笔记(六)红外图像伪彩色编码
- [leetcode daily question 2021/4/23]368. Maximum divisible subset
- 父类对子类的引用(父类引用指向子类对象)
- Issue 5: the second essential skill for College Students
- RT-Thread 学习笔记(七)---开启基于SPI Flash的elmfat文件系统(中)
- Simple use of json-c Library -- converting JSON files to struct
- router.push(),router.repalce(),router.go()使用
- 英语基础句型结构------起源
- 剑指Offer(四十九):把字符串转换成整数
猜你喜欢

.net5wtm (asp.net core) PgSQL unpacking operation

Introduction to data analysis | kaggle Titanic mission (I) - > data loading and preliminary observation

在altium designer中禁用USBJATG

STM32 阿里云MQTT esp8266 AT命令

IAR sprintf 浮点 在UCOS 总格式化成0.0的问题

Issue 6: which mainstream programming language should college students choose

Issue 5: the second essential skill for College Students

【机器学习小记】【人脸识别】deeplearning.ai course4 4th week programming

英语基础句型结构------起源
![[notes on machine learning] [building a cyclic neural network and its application] deeplearning ai course5 1st week programming(keras)](/img/02/f85da2a2f2524fb034b17ed8d06692.png)
[notes on machine learning] [building a cyclic neural network and its application] deeplearning ai course5 1st week programming(keras)
随机推荐
RT-Thread 学习笔记(六)--- 开启基于SPI Flash的elmfat文件系统(上)
QRcode二维码(C语言)遇到的问题
GIS方法类期刊和论文的综述(Introduction)怎么写?
Application of.Net open source framework in industrial production
[leetcode daily question 2021/4/29]403. Frogs cross the river
控制随机抽中几率 [ C# | Random ]
.NET操作Redis List列表
RT-Thread 学习笔记(三)---用SCons 构建编译环境
[leetcode每日一题2021/4/29]403. 青蛙过河
$router和$route的区别
Navicat15 MySQL (centos7) connected to local virtual machine
第4期:大学生提前职业技能准备之一
同步方法中不使用asyncTask<T> 修饰和await获取异步返回值(同步方法中调用异步方法)
13 以对象管理资源
SuperMap IClient for Leaflet 加载高斯克吕格投影三度分带CGCS2000大地坐标系WMTS服务
剑指Offer(四十三):左旋转字符串
Oracle创建索引
[leetcode daily question 2021/4/23]368. Maximum divisible subset
.net operation redis sorted set ordered set
剑指Offer(四十九):把字符串转换成整数