zoukankan      html  css  js  c++  java
  • [C++]左值和右值(LValue and RVaule)

    左值(LValue)和右值(RValue)的一个快捷记法是赋值运算,左值是赋值运算左边的值,右值就是右边(=,=废话)。例如:

    int a = 5;

    a就是左值,5就是右值。

    当然,如果真是这么个含义,那么这概念就相当蛋疼了。其实不是这样的~~

    左值其实是对一块内存区域的引用(这个还不是C++中的int &a之类的引用),比如上边的a,就对应了一块内存区域(起始地址为&a,大小为sizeof(int))。

    更专业的定义在这里:

    An object is a region of storage that can be examined and stored into. An lvalue is an expression that refers to such an object. An lvalue does not necessarily permit modification of the object it designates. For example, a const object is an lvalue that cannot be modified.

    右值对应的玩意其实也在内存里,但是我们忽略这一点,认为它存在于冥冥之中。例如上边那个5,其实它在静态数据段或者程序二级制代码中,但我们不关心这个,认为它无法修改。

    附个链接:

    http://publib.boulder.ibm.com/infocenter/comphelp/v7v91/index.jsp?topic=%2Fcom.ibm.vacpp7a.doc%2Flanguage%2Fref%2Fclrc05lvalue.htm

  • 相关阅读:
    HTTP响应状态码整理
    Python通用爬虫,聚焦爬虫概念理解
    HTTP无状态协议理解
    会话与事务知识点总结
    并发一致性知识点整理
    使用隔离级别read committed隐式解决并发冲突
    多并发笔记整理
    git基本使用
    Docker其他
    Docker Bind Mount 与 Volume
  • 原文地址:https://www.cnblogs.com/SelaSelah/p/2497686.html
Copyright © 2011-2022 走看看