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

边栏推荐
- 6-6漏洞利用-SSH安全防御
- C语言练习题_1
- PSINS中19维组合导航模块sinsgps详解(时间同步部分)
- Redis入门完整教程:客户端案例分析
- Oracle中日期的使用方法实例
- Summary of research status of inertial navigation calibration at home and abroad (abridged version)
- Google Earth engine (GEE) -- 1975 dataset of Landsat global land survey
- 哈希表及完整注释
- The panel floating with the mouse in unity can adapt to the size of text content
- Cloud Mail .NET Edition
猜你喜欢

数论 --- 快速幂、快速幂求逆元

运维管理系统有哪些特色

6-6 vulnerability exploitation SSH security defense

Cloud Mail . NET Edition

Google Earth Engine(GEE)——Landsat 全球土地调查 1975年数据集

你不可不知道的Selenium 8种元素定位方法,简单且实用

测试优惠券要怎么写测试用例?

How to design interface test cases? Teach you a few tips to draft easily

Software testing -- common assertions of JMeter interface testing

uniapp的表单验证
随机推荐
The annual salary of general test is 15W, and the annual salary of test and development is 30w+. What is the difference between the two?
MES管理系统的应用和好处有哪些
Difference and the difference between array and array structure and linked list
一文读懂Faster RCNN
测试优惠券要怎么写测试用例?
【2022国赛模拟】多边形——计算几何、二分答案、倍增
[leetcode]Search for a Range
Redis入门完整教程:RDB持久化
Contribution of Writing Series
MySQL
wireshark安装
安全交付工程师
Matlb| economic scheduling with energy storage, opportunity constraints and robust optimization
6-6 vulnerability exploitation SSH security defense
Station B's June ranking list - feigua data up main growth ranking list (BiliBili platform) is released!
ERROR: Could not find a version that satisfies the requirement xxxxx (from versions: none)解决办法
MetaForce原力元宇宙佛萨奇2.0智能合约系统开发(源码部署)
S120驱动器基本调试步骤总结
Apifox, is your API interface document rolled up like this?
Rethinking of investment