在程序的数据段中分配什么类型的变量? [英] What type of variables are allocated in data segment of a program?
本文介绍了在程序的数据段中分配什么类型的变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请在程序的数据段中列出,声明了什么类型的变量/具有内存?
In data segment of a program, please list,what type of variables are declared/have memory?
推荐答案
类和结构的所有静态字段.如果它们是引用类型,则引用存储在数据段中,而对象本身存储在堆中.
使用C ++/CLI,情况更加复杂.这种语言是唯一的,因为它甚至允许引用类型实现值语义.并且显式声明了托管引用("^
").因此,即使引用类型的静态对象也可以存储在数据段中.仅当对引用类型的对象的引用表示静态字段时,该引用才存储在数据段中,而对象本身存储在堆中.
通常,如果使用gcnew
(对于C#为new
),则引用类型对象存储在堆中.
—SA
All static fields of classes and structures. If they are of a reference type, the reference is stored in data segment, and the object itself — in the heap.
With C++/CLI, the situation is more complex. This language is unique as it allows for value semantic even for reference types; and the managed references are declared explicitly (''^
''). So even the static object of reference type can be stored in the data segment. Only if a static field is represented by the reference to the object of reference type, the reference is stored in the data segment and the object itself in the heap.
Generally, reference-type objects are stored in the heap ifgcnew
(new
for C#) is used.
—SA
这篇关于在程序的数据段中分配什么类型的变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文