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 meant by oops concept?

819


What is the real life example of polymorphism?

879


Why do we use encapsulation in oops?

785


What do you mean by overloading?

834


How can you overcome the diamond problem in inheritance?

985


how to get the oracle certification? send me the answer

1928


Is enum a class?

827


Which is better struts or spring?

835


What is the oops and benefits of oops programming?

770


2. Give the different notations for the class.\

1846


Write a java applet that computes and displays the squares of values between 25 and 1 inclusive and displays them in a TextArea box

2311


What is static modifier?

877


What does enum stand for?

902


i=20;k=0; for(j=1;k-i;k+=j<10?4:3) { cout<

1658


c++ program to swap the objects of two different classes

2158