Click here to Skip to main content
15,886,530 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
In data segment of a program, please list,what type of variables are declared/have memory?
Posted
Comments
Debojyoti Majumder 27-Jul-11 1:48am    
What information acctually you want??
Your question is not clear.
ahsanriaz1K 27-Jul-11 2:06am    
Each program has four data segments, one of which is data segment, i want list, In data segment of a program, please list,what type of variables are declared/have memory?

1 solution

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 if gcnew (new for C#) is used.

—SA
 
Share this answer
 
v2
Comments
ahsanriaz1K 27-Jul-11 2:08am    
local static variables?(inside a function)
Sergey Alexandrovich Kryukov 27-Jul-11 2:09am    
Not possible, not in .NET, local declarations will not compile with the key word 'static'.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900