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 :( :-?
Answer Posted / 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 |
Post New Answer View All Answers
what are the realtime excercises in C++?
what type of question are asked in thoughtworks pair programming round ?
Why is polymorphism important in oop?
What are main features of oop?
What are oops methods?
write a program to find 2^n+1 ?
How oops is better than procedural?
What does enum stand for?
Where You Can Use Interface in your Project
Give two or more real cenario of virtual function and vertual object
What is the difference between inheritance and polymorphism?
Why is there no multiple inheritance?
What is the purpose of polymorphism?
What polymorphism means?
what are the different types of qualifier in java?