当前位置:网站首页>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 .
边栏推荐
- Here comes a white paper to uncover the technology behind Clickhouse, a node with 10000 bytes!
- MySQL is an optimization artifact to improve the efficiency of massive data query
- AWS学习笔记(一)
- 软件测试——Jmeter接口测试之常用断言
- Oracle中日期的使用方法实例
- Cloud Mail .NET Edition
- Google Earth Engine(GEE)——Landsat 全球土地调查 1975年数据集
- Redis getting started complete tutorial: common exceptions on the client
- 一本揭秘字节万台节点ClickHouse背后技术实现的白皮书来了!
- Qpushbutton- "function refinement"
猜你喜欢
随机推荐
Andrews - multimedia programming
Redis Getting started tutoriel complet: positionnement et optimisation des problèmes
Digital scrolling increases effect
Dotconnect for DB2 Data Provider
Redis入门完整教程:AOF持久化
AWS学习笔记(一)
牛客编程题--必刷101之双指针篇
写作系列之contribution
Redis getting started complete tutorial: client management
QT常见概念-1
The 8 element positioning methods of selenium that you have to know are simple and practical
Remember the problem analysis of oom caused by a Jap query
从零安装Redis
Detailed explanation of 19 dimensional integrated navigation module sinsgps in psins (initial assignment part)
MySQL --- 常用函数 - 字符串函数
差异与阵列和阵列结构和链表的区别
Linear list --- circular linked list
Niuke programming problem -- double pointer of 101 must be brushed
Wireshark installation
AWS learning notes (I)