什么是“指定对象”用C是什么意思? [英] What does 'designate an object' mean in C?
问题描述
例如,
INT X = 10;
我们说, X
指定存储10 int对象。但什么是指定究竟是什么意思?这是否意味着 X
的行为就像是指内存的整个块的标签?
-
X
是标识符的 - 有一个
INT
对象(即存储的区域)包含值10
。 - 标识符
X
是与INT
对象关联。
C标准使用英文单词候来恩preSS的之间的关系识别符和它标识对象。你可以说,在几种不同的方式同样的事情。我说:联想只是现在,还有我们可以选择很多的话。 X
是本地区一个内存标签将是另一种方式。
注意:指定不局限于标识符。其他前pressions可以指定一个对象了。例如 *(&安培; X)
也表示相同的对象一样, *(&安培; X + 0)
当一个前pression指定的对象,前pression可用于一个值分配给对象,或检索从对象的值。 (同样的语法涵盖的那些情况下,它依赖于上下文的值是否是读或写)。
字的左值的指前pression可能会指定一个对象(按候的上述定义)。
For example,
int x = 10;
we say that "x
designates an int object which stores 10". But what does "designate" exactly mean? Does it mean x
behaves like a label which refers to the whole chunk of memory?
x
is an identifier.- There is an
int
object (i.e. a region of storage) containing the value10
. - The identifier
x
is associated with thatint
object.
The C standard uses the English word designate to express the relationship between an identifier and the object it identifies. You could say the same thing in several different ways. I said "associate" just now, there are many words we could choose. "x
is a label for this region of memory" would be another way.
Note: designating is not limited to identifiers. Other expressions can designate an object too. For example *(&x)
also designates the same object, as does *(&x + 0)
.
When an expression designates an object, the expression may be used to either assign a value to the object, or retrieve the value from the object. (The same syntax covers both of those cases; it depends on context whether the value is read or written).
The word lvalue means an expression that might designate an object (according to the above definition of 'designate').
这篇关于什么是“指定对象”用C是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!