当前位置:网站首页>左值引用和右值引用
左值引用和右值引用
2022-06-30 20:00:00 【兔云程序】
什么是引用
引用就是给已经存在的变量取得一个别名,而不是新定义一个变量。编译器不会为引用变量开辟新得内存空间,引用变量和引用的变量共用同一内存空间。
引用的规则
引用在定义时必须初始化
一个变量可以有多个引用
引用一旦引用一个实体,不能再引用其它实体
什么是左值,右值
右值引用是C++ 11新增的特性,左值引用从C++ 98就开始有。
目前我们针对C++编程语言。
左值(left-values),缩写:lvalues
右值(right-values),缩写:rvalues
你可以通俗的理解lvalues是指存在于单个表达式之外的对象。你可以把左值当成有名字的对象。
rvalues是一个暂时存在的值存在于单个表达式之内的对象。简单来说,右值就是一个生命周期即将结束的值。也叫将亡值。
以下为官网所写的原理
边栏推荐
- VB的基本语法
- Filebeat自定义index和fields
- CV+Deep Learning——网络架构Pytorch复现系列——basenets(BackBones)(一)
- Web主机iptables防火墙安全脚本
- 以全栈全功能解决方案,应对多样工具复杂环境DevOps落地难题
- 杰理之检测灵敏度级别确定【篇】
- Tensorflow2.4实现RepVGG
- Summary of operating system interview questions (updated from time to time)
- originpro 2021 附安装教程
- Great God detailed open source Buff gain Introduction 丨 Live
猜你喜欢
Transport layer uses sliding window to realize flow control
Jerry's touch key recognition process [chapter]
Exness: the final value of US GDP unexpectedly accelerated to shrink by 1.6%
Document contains & conditional competition
如何快速通过PMP考试?
Maya house modeling
[try to hack] windows system account security
Network planning | [five transport layers and six application layers] knowledge points and examples
Implementation principle of PostgreSQL heap table storage engine
Is the project manager a leader? Can you criticize and blame members?
随机推荐
广州股票开户选择手机办理安全吗?
Common questions and answering skills of project manager interview
Is it safe to open an account in Guangzhou stock exchange by mobile phone?
Go language identifier and package name specification
Openfire在使用MySQL数据库后的中文乱码问题解决
C语言:hashTable
杰理之关于长按开机检测抬起问题【篇】
Meeting, onemeeting, OK!
The Commission is so high that everyone can participate in the new programmer's partner plan
QT qstringlist usage
Data intelligence - dtcc2022! China database technology conference is about to open
Description of the latest RTSP address rules for Hikvision camera, NVR, streaming media server, playback and streaming [easy to understand]
Is the project manager a leader? Can you criticize and blame members?
Mistakes the project manager should not make
Tensorflow2.4 implementation of repvgg
unittest自动测试多个用例时,logging模块重复打印解决
Ten percent of the time, the tar command can't parse the English bracket "()" when decompressing the file
杰理之关于长按开机检测抬起问题【篇】
传输层 使用滑动窗口实现流量控制
Client请求外部接口标准处理方式