当前位置:网站首页>Left value, right value
Left value, right value
2022-07-07 02:51:00 【Qiange】
The left value 、 Right value
1. Basic concepts
(1)
The left value : You can take its address
Right value : You can't take its address
int main()
{
//int& a=10;// error : An lvalue reference cannot reference a constant , Lvalue reference is equivalent to :int* const( Constant pointer ),
const int& a=10;// correct
/* Equivalent to : int tmp=10; const int* const a=&tmp; */
}
(2)
int fun()
{
int a=10;
return a;
}
int main()
{
int x=fun();
//int& b=fun(); error
const int& c=fun();// correct
int&& d=fun();
return 0;
}
The analysis of the above code is as follows :
2. lvalue reference 、 Right quoting
(1)
lvalue reference : You need to reference a variable with a name , You cannot reference an unnamed object .
Right quoting : Only literal constants can be referenced , No name .
Because will die value is an unnamed object , So you can't use lvalue to reference , Can only be referenced with an R-value , And through the right value reference , It also increases the life cycle of the dying value .
3. Mobile build :
The heap memory is built once , If there is no mobile build , It will be built three times
notes : If there is a moving object, first mobilize the moving structure to frame the dead value object , Instead of calling ordinary copy constructs , If you don't move the structure , The normal copy construct will be called to construct the dead value object .

边栏推荐
- Number theory --- fast power, fast power inverse element
- MATLB|具有储能的经济调度及机会约束和鲁棒优化
- 1 -- Xintang nuc980 nuc980 porting uboot, starting from external mx25l
- Compress JS code with terser
- 数论 --- 快速幂、快速幂求逆元
- 安全交付工程师
- Apifox, is your API interface document rolled up like this?
- Apifox,你的API接口文档卷成这样了吗?
- Unity webgl adaptive web page size
- Qpushbutton- "function refinement"
猜你喜欢

3 -- Xintang nuc980 kernel supports JFFS2, JFFS2 file system production, kernel mount JFFS2, uboot network port settings, and uboot supports TFTP

6-6 vulnerability exploitation SSH security defense

What are the applications and benefits of MES management system

进程管理基础

实施MES管理系统时,哪些管理点是需要注意的

Es6中Promise的使用

Niuke programming problem -- double pointer of 101 must be brushed

MySQL --- 常用函数 - 字符串函数

Qt蓝牙:QBluetoothDeviceInfo

服装企业部署MES管理系统的五个原因
随机推荐
普通测试年薪15w,测试开发年薪30w+,二者差距在哪?
Leetcode:minimum_ depth_ of_ binary_ Tree solutions
测试优惠券要怎么写测试用例?
Digital scrolling increases effect
Dotconnect for DB2 Data Provider
一本揭秘字节万台节点ClickHouse背后技术实现的白皮书来了!
uniapp的表单验证
QPushButton-》函数精解
Examples of how to use dates in Oracle
MySQL
普通测试年薪15w,测试开发年薪30w+,二者差距在哪?
Apifox,你的API接口文档卷成这样了吗?
CSDN 夏令营课程 项目分析
[leetcode]Search for a Range
Qpushbutton- "function refinement"
The so-called consumer Internet only matches and connects industry information, and does not change the industry itself
MySQL
unity中跟随鼠标浮动的面板,并可以自适应文字内容的大小
Leetcode:minimum_depth_of_binary_tree解决问题的方法
MySQL is an optimization artifact to improve the efficiency of massive data query