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 is meant by multiple inheritance?
Write a program to implement OOPS concepts such as inheritance, polymorphism, friend function, operator overloading?
What is the important feature of inheritance?
i got a backdoor offer in process global,Bangalore..Can i work with it?
What is static in oop?
What is polymorphism in oop example?
what is different between oops and c++
What are the advantages of polymorphism?
What is multilevel inheritance?
can we make game by using c
What is overloading in oops?
What are constructors in oop?
Can static class have constructor?
What is class encapsulation?
Give two or more real cenario of virtual function and vertual object