Attributes that variables (and other objects) may possess.

本文探讨了计算机科学中对象的不同属性,如变量名、内存地址、运行时值等,并介绍了静态对象与动态对象的概念及其属性绑定过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

8.2.1 Attributes


An attribute is some feature that is associated with an object.

For example, common attributes of a variable include that variable’s name, its memory address, its runtime value, a data type associated with that value, and the size (in bytes) of that variable.

Different objects may have different sets of attributes.

For example, a data type is an object that possesses attributes such as a name and size, but it won’t usually have a value or memory location associated with it.

A constant can have attributes such as a value and a data type, but it does not have a memory location and it might not have a name (for example, if it is a literal constant).

A variable may possess all of these attributes.

Indeed, the attribute list usually determines whether an object is a constant, data type, variable, or something else.

 

8.2.2 Binding

 

Binding is the process of associating an attribute with an object.

For example, when a value is assigned to a variable, the value is bound to that variable at the point of the assignment. The value remains bound to the variable until some other value is bound to it (via another assignment operation).

Likewise, if you allocate memory for a variable while the program is running, the variable is bound to the memory address at that point. The variable and address are bound until you associate a different address with the variable. Binding needn’t occur at runtime.

For example, values are bound to constant objects during compilation, and such bindings cannot change while the program is running.

Similarly, some variables can have their address bound to them at compile time, and the memory address cannot change during program execution.

 

8.2.3 Static Objects

Static objects have an attribute bound to them prior to the execution of the application.

Constants are good examples of static objects; they have the same value bound to them throughout the execution of the application. Global (program-level) variables in programming languages like Pascal, C/ C++, and Ada are also examples of static objects because they have the same memory address bound to them throughout the program’s lifetime. The system binds attributes to a static object before the program begins execution (usually during compilation or during the linking phase, though it is possible to bind values even earlier).

8.2.4 Dynamic Objects

Dynamic objects have some attribute bound to them during program execution. The program may choose to change that attribute (dynamically) while the program is running. Dynamic attributes usually cannot be determined at compile time. Examples of dynamic attributes include values bound to variables at runtime and memory addresses bound to certain variables at runtime (e.g., via a malloc or other memory allocation function call).

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值