where is memory for struct allocated?
where is memory for class-object allocated?
I replied for struct in stack and for class-object in heap.
THen he asked if class has struct member variable what
happens.class on heap and what about struct in that class?
couldnt ans :( :-?
Answers were Sorted based on User's Feedback
Answer / rajanikanth
variable: value type lives on the stack, reference type lives on the stack as a pointer to somewhere in heap memory where the actual memory lives
class/struct-field: value type lives inside the class, reference type lives inside the class as a pointer to somewhere in heap memory where the actual memory lives.
Is This Answer Correct ? | 6 Yes | 1 No |
Answer / vishwa
Both are allocated in heap.
Also if any structure is declared in a function, the
function stack creates a heap from the stack. so these
structures in function allocates in heap.
Is This Answer Correct ? | 3 Yes | 2 No |
Difference between over loading and over ridding?
12 Answers CTS, Patni, Softvision Solution,
i got a backdoor offer in process global,Bangalore..Can i work with it?
Explain polymorphism? What r the types of polymorphism? pls give examples?
Why is oop better than procedural?
what is object slicing?
What is constructor overloading in oop?
program for insertion ,deletion,sorting in double link list
What is encapsulation with example?
what is a virtual class?
5 Answers Cap Gemini, IBM, Infosys, Trinity Technologies,
How can i write a code in c# to take a number from the user and then find all the prime numbers till the number entered by the user.
can main method be overloaded...??? How..????
what is different between oops and c++