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 class and example?
How do you define a class in oop?
What is difference between oop and pop?
i=20;k=0;
for(j=1;k-i;k+=j<10?4:3)
{
cout< What is Difeerence between List obj=new ArrayList(); and
ArrayList obj=new ArrayList()? What is encapsulation in simple terms? What is encapsulation in ict? Can destructor be overloaded? What are the 4 main oop principles? Following are the class specifications:
class {int a};
class {int b};
Using friend funtion,calculate the max of two objects and
display it.
what are the ways in which a constructors can be called? What is destructor in oop? What does <> mean pseudocode? what type of questions What is a superclass in oop?