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 oops concept?
What is the real life example of polymorphism?
Why do we use encapsulation in oops?
What do you mean by overloading?
How can you overcome the diamond problem in inheritance?
how to get the oracle certification? send me the answer
Is enum a class?
Which is better struts or spring?
What is the oops and benefits of oops programming?
2. Give the different notations for the class.\
Write a java applet that computes and displays the squares of values between 25 and 1 inclusive and displays them in a TextArea box
What is static modifier?
What does enum stand for?
i=20;k=0;
for(j=1;k-i;k+=j<10?4:3)
{
cout<
c++ program to swap the objects of two different classes