`
weihe6666
  • 浏览: 432856 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

C++里面的lvalue 和 rvalue的释义

阅读更多
Definition: C and C++ have the notion of lvalues and rvalues associated with variables and constants. The rvalue is the data value of the variable, that is, what information it contains. The "r" in rvalue can be thought of as "read" value. A variable also has an associated lvalue. The "l" in lvalue can be though of as location, meaning that a variable has a location that data or information can be put into. This is contrasted with a constant. A constant has some data value, that is an rvalue. But, it cannot be written to. It does not have an lvalue.

Another view of these terms is that objects with an rvalue, namely a variable or a constant can appear on the right hand side of a statement. They have some data value that can be manipulated. Only objects with an lvalue, such as variable, can appear on the left hand side of a statement. An object must be addressable to store a value.

Here are two examples.

int x;

x = 5; // This is fine, 5 is an rvalue, x can be an lvalue.

5 = x; // This is illegal. A literal constant such as 5 is not

// addressable. It cannot be a lvalue.

这段就说的很明白lvalue中的l其实指的表示该值的存储地址属性,而另外一个相对的词rvalue值中的r指的是read的属性,和左右根本没有任何关系。
分享到:
评论

相关推荐

    理解C++ lvalue与rvalue

    而左值(lvalue)和右值(rvalue)的概念,本质上,是理解“程序员可以放心使用的变量”。  空泛的讨论先到这里,先看一段会报错的代码: #include using std::cout; using std::endl; int foo(int &a) { ...

    Mastering the C++17 .pdf

    The C++ language has a long history, dating back to the 1980s. Recently it has undergone a renaissance, ...class and function templates, the difference between lvalue and rvalue references, and so on.

    C++11中value category(值类别)及move semantics(移动语义)的介绍

    C++11之前value categories只有两类,lvalue和rvalue,在C++11之后出现了新的value categories,即prvalue, glvalue, xvalue。不理解value categories可能会让我们遇到一些坑时不知怎么去修改,所以理解value ...

    [Visual.C++.2010入门经典(第5版)].Ivor.Horton.part1

    2.10 lvalue和rvalue 73 2.11 了解存储时间和作用域 74 2.11.1 自动变量 74 2.11.2 决定变量声明的位置 76 2.11.3 全局变量 77 2.11.4 静态变量 80 2.12 名称空间 80 2.12.1 声明名称空间 81 2.12.2 多个名称空间 82...

    visualC++2010入门经典源代码

    2.10 lvalue和rvalue 73 2.11 了解存储时间和作用域 74 2.11.1 自动变量 74 2.11.2 决定变量声明的位置 76 2.11.3 全局变量 77 2.11.4 静态变量 80 2.12 名称空间 80 2.12.1 声明名称空间 81 2.12.2 多个...

    Visual C++ 2010入门经典(第5版)--源代码及课后练习答案

    2.10 lvalue和rvalue 73 2.11 了解存储时间和作用域 74 2.11.1 自动变量 74 2.11.2 决定变量声明的位置 76 2.11.3 全局变量 77 2.11.4 静态变量 80 2.12 名称空间 80 2.12.1 声明名称空间 81 2.12.2 多个...

    c++的左值右值 i++与++i的区别.docx

    在 C++ 编程语言中,左值(Lvalue)和右值(Rvalue)是两个重要的概念,它们在变量和表达式中的角色不同,理解这两个概念对于编写正确和高效的代码非常重要。 左值(Lvalue)是指可以出现在赋值语句左侧的表达式,...

    C++中的左值和右值

    在C/C++中,左值(lvalue)和右值(rvalue)是用于规定表达式(expression)的性质。C++中表达式要不然是左值,要不然是右值。  这两个概念在C语言中比较容易理解:左值能放在赋值语句的左边,右值不能。但是当来到C++时...

    C++11右值引用和转发型引用教程详解

    为了解决移动语义及完美转发问题,C++11标准引入了右值引用(rvalue reference)这一重要的新概念。右值引用采用T&&这一语法形式,比传统的引用T&(如今被称作左值引用 lvalue reference)多一个&。 如果把经由T&&...

    lvalue

    lvalue

    c++11 Value Terminology

    c++11 Value Terminology

    Google C++ International Standard.pdf

    7.1 Lvalue-to-rvalue conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 7.2 Array-to-pointer conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....

    C++中的delete不会将操作数置0

    考虑一下: delete p; // ... delete p; 如果在…部分没有涉及到p 的话,那么第二个“delete p;”将是一个严重的错误,因为C++的...一个原因是,delete 的操作数并不需要一个左值(lvalue)。考虑一下: dele

    lvalues:经典和量子程序中的LValue

    lvalues:经典和量子程序中的LValue

    Tecplot中如何用公式修改数据.doc

    Lvalue = f(Rvalue1, Rvalue2, Rvalue3, ...) 其中,Lvalue 是对一个存在或不存在的变量的引用,RvalueN 是对值的引用(如常数、变量值或序号)。公式中可以有空格,但是在内部函数名称和变量名称中不能有空格。...

    insert_const_lvalue.rar_return

    wfc_util_qcom_check_config((unsigned char )macAddress) return 0 .

    C++ 标准 ISO 14882-2011

    4.1 Lvalue-to-rvalue conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 4.2 Array-to-pointer conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....

    sonsole-lvalue.rar_3AJW_tobaccoujz

    学习开发opcclient的好例子,结构清晰

    insert_const_lvalue.rar_V2 _llvm

    The LLVM Compiler Infrastructure Kernel Device Driver for linux v2.13.6.

    嵌入式LinuxC语言面试试题1.pdf

    1. C 语言的左值 (lvalue) 和右值 (rvalue) 的含义是什么?答:左值是指可以出现在赋值符号左侧的表达式,右值是指可以出现在赋值符号右侧的表达式; 九、 可变参数 1. 为什么 C 语言可以实现 printf(char *format,...

Global site tag (gtag.js) - Google Analytics