linux初探

首页

应用服务器

Linux技巧

中文文档

Linux初级

服务器源代码

命令详解

Linux技术应用

Linux安全应用

Linux业界新闻

UniX技术文章

Linux编程与内核

Linux数据库

Linux服务器

Linux安装指导

Linux论坛


首页>>Linux编程与内核>>

热门文章

·C/C++中多维数组指针作为函数
·教你如何使用 C++Builder 制
·C++ Builder中保持控件的位置
·C++Builder中动态更改自定义
·拓展网页技术之C++在网页设计
·C++Builder创建基于Internet
·C++Builder在WIN2000环境下编
·用C++ Builder为计算机增加启
·C++/VC++ 语言编程的疑难问题
·C/C++语言void及void指针深层

推荐文章

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


作者: nathanxu
在看GCC的文档的时候,看到一个词lvalue,查了金山词霸其释义为 lvalue [计] 左值。因为的确在介绍编译原理的课程中听过这个词,大致知道其意思就没有多想。但是看完GCC文档的这个篇幅,都无法明白全篇在说什么。问题还是出在了 lvalue这个词的“左值”是什么意思的理解上了。再找M-W字典,却告知没有这个词。于是google了一把,的确很多地方都称其为左值,我仍然不得要领。最后在一个百科网站About Site上找到该词的准确释义,摘贴如下:
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++程序中导出Word文档的方法
·C++中控制Windows关机的实用技巧
·C++中用函数模板实现和优化抽象操作
·C++对象布局及多态实现之动态和强制转换
·C++类对象的深拷贝、浅拷贝构造函数
·c/c++数组排序、计算平均值、最大、小值
·C/C++语言void及void指针深层探索
·C++/VC++ 语言编程的疑难问题及解答
·用C++ Builder为计算机增加启动日志

Copyright@2005 www.linuxGoo.com All Right Reserved