当前位置:网站首页>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 .

边栏推荐
- 【Node学习笔记】chokidar模块实现文件监听
- 1 -- Xintang nuc980 nuc980 porting uboot, starting from external mx25l
- Software testing -- common assertions of JMeter interface testing
- 测试优惠券要怎么写测试用例?
- 一本揭秘字节万台节点ClickHouse背后技术实现的白皮书来了!
- Safety delivery engineer
- MES管理系统的应用和好处有哪些
- 记一次JAP查询导致OOM的问题分析
- 数论 --- 快速幂、快速幂求逆元
- Have fun | latest progress of "spacecraft program" activities
猜你喜欢
随机推荐
Statistics of radar data in nuscenes data set
MetaForce原力元宇宙佛萨奇2.0智能合约系统开发(源码部署)
Here comes a white paper to uncover the technology behind Clickhouse, a node with 10000 bytes!
MySQL提升大量数据查询效率的优化神器
如何设计好接口测试用例?教你几个小技巧,轻松稿定
LeetCode 77:组合
What are the applications and benefits of MES management system
普通测试年薪15w,测试开发年薪30w+,二者差距在哪?
C language exercises_ one
Detailed explanation of 19 dimensional integrated navigation module sinsgps in psins (initial assignment part)
Station B's June ranking list - feigua data up main growth ranking list (BiliBili platform) is released!
MMDetection3D加载毫米波雷达数据
记一次JAP查询导致OOM的问题分析
Contribution of Writing Series
Apifox,你的API接口文档卷成这样了吗?
The third season of ape table school is about to launch, opening a new vision for developers under the wave of going to sea
你不可不知道的Selenium 8种元素定位方法,简单且实用
用全连接+softmax对图片的feature进行分类
How to design interface test cases? Teach you a few tips to draft easily
Static proxy of proxy mode









