c - C语言中 'objects'是什么意思?

标签 c object

在 Jens Gustedt 的《Modern C》一书中,作者做出了以下陈述:

  1. In the following subsections, we will introduce the syntactical aspects (grammar) and three different semantic aspects: declarative parts (what things are), definitions of objects (where things are), and statements (what things are supposed to do).

  2. The declarations of i and A declare variables , which are named items that allow us to store values. They are best visualized as a kind of box that may contain a “something” of a particular type:

    enter image description here

    Conceptually, it is important to distinguish the box itself (the object), the specification (its type), the box contents (its value), and the name or label that is written on the box (the identifier). In such diagrams, we put ?? if we don’t know the actual value of an item.

  3. Generally, declarations only specify the kind of object an identifier refers to, not what the concrete value of an identifier is, nor where the object it refers to can be found. This important role is filled by a definition.

关于上述陈述的问题:

  1. 作者的第一和第三个陈述暗示定义指定了标识符引用的对象的位置。 “哪里”在这里是什么意思,特别是如何在定义中指定标识符的具体值与标识符所指的对象所在的位置相同/不同?

  2. 根据陈述 2,什么是 '从概念上讲,区分盒子本身(对象)、规范(其类型)、盒子内容(其值)以及名称或标签很重要写在盒子上(标识符)。意思是?为什么这里的“盒子”是对象而不是“盒子”中的值?

最佳答案

对象是可以存储值的地方。这是该语言使用的术语。

形式上,一个对象是一个

region of data storage in the execution environment, the contents of which can represent values

https://port70.net/~nsz/c/c11/n1570.html#3.15p1

本书作者使用了“盒子”这个词,这在非正式讨论中是完全合适的。

关于c - C语言中 'objects'是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72210270/

相关文章:

javascript - JavaScript 中 hasOwnProperty 中的属性是什么?

javascript - 重新创建对象数组的方法返回重复相同对象的相同数组

javascript - 检查数组中是否存在具有特定属性的对象

c - ARM 汇编程序 - 如何使用 CMP、BLT 和 BGT?

c - gcc -march= native 。检测为错误架构构建的二进制文件的方法?

c - WPF : How can I sendkeys to another control without taking focus away from the target control

c++ - 带有位置通知的音频流

C 使用 system() 与使用 execl() 启动 X11 session

javascript - 如何将对象属性重置为默认属性?

java - java中将对象赋值给变量