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


Please Help Members By Posting Answers For Below Questions

What is overloading in oop?

577


How to handle exception in c++, For example in a functions i am assigning memory to some variables and also in next instructions in am dividing one variable also. If this functions generates a error while allocating memory to those variable and also while dividing the variable if i divide by zero then catch block how it will identify that this error has cone from perticular instruction

1653


Why do we need polymorphism in c#?

688


what type of questions

1697


What are the data types in oop?

608






Why multiple inheritance is not allowed?

584


How do you achieve polymorphism?

618


Can a destructor be called directly?

603


• What are the desirable attributes for memory managment?

1728


How oops is better than procedural?

589


hi, this is raju,iam studying b.tech 2nd year,iam want know about group1 and group2 details, and we can studying without going to any instutions? please help me.

1542


what's the basic's in dot net

1740


What is inheritance in oop?

604


2. Give the different notations for the class.\

1594


What is stream in oop?

841