当前位置:网站首页>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 .
边栏推荐
- Five reasons for clothing enterprises to deploy MES management system
- Matlb| economic scheduling with energy storage, opportunity constraints and robust optimization
- How to write test cases for test coupons?
- Redis入门完整教程:复制配置
- Django database (SQLite) basic introductory tutorial
- 安德鲁斯—-多媒体编程
- MySQL --- 常用函数 - 字符串函数
- dotConnect for DB2数据提供者
- 如何设计好接口测试用例?教你几个小技巧,轻松稿定
- CDB PDB user rights management
猜你喜欢
A complete tutorial for getting started with redis: RDB persistence
3 -- Xintang nuc980 kernel supports JFFS2, JFFS2 file system production, kernel mount JFFS2, uboot network port settings, and uboot supports TFTP
Digital scrolling increases effect
Redis入门完整教程:客户端案例分析
6-6漏洞利用-SSH安全防御
进程管理基础
uniapp的表单验证
ERROR: Could not find a version that satisfies the requirement xxxxx (from versions: none)解决办法
AWS learning notes (I)
Apifox,你的API接口文档卷成这样了吗?
随机推荐
dotConnect for DB2数据提供者
CSDN summer camp course project analysis
MySQL
Cloud Mail .NET Edition
Remember the problem analysis of oom caused by a Jap query
uniapp的表单验证
Andrews - multimedia programming
一本揭秘字节万台节点ClickHouse背后技术实现的白皮书来了!
Redis Getting started tutoriel complet: positionnement et optimisation des problèmes
Detailed explanation of 19 dimensional integrated navigation module sinsgps in psins (time synchronization part)
widerperson数据集转化为YOLO格式
从零安装Redis
MySQL --- 常用函数 - 字符串函数
Summary of basic debugging steps of S120 driver
Redis入门完整教程:问题定位与优化
Common fitting models and application methods of PCL
unity 自定义webgl打包模板
6-6 vulnerability exploitation SSH security defense
测试优惠券要怎么写测试用例?
ODBC database connection of MFC windows programming [147] (with source code)