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 / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Give two or more real cenario of virtual function and vertual object

1843


Is oop better than procedural?

558


Will I be able to get a picture in D drive to the c++ program? If so, help me out?

1644


Why multiple inheritance is not possible?

588


What is the significance of classes in oop?

579






What is basic concept of oop?

684


Can a destructor be called directly?

589


Write a program to sort the number with different sorts in one program ??

1905


What is static in oop?

579


What is static modifier?

623


What is multilevel inheritance in oop?

544


Can bst contain duplicates?

660


What is overriding vs overloading?

571


What is polymorphism in oop example?

505


Why is there no multiple inheritance?

558