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 an example of genetic polymorphism?
What do you mean by overloading?
program for insertion ,deletion,sorting in double link list
What are the benefits of interface?
What is class and object with example?
Why is abstraction used?
just right the logic of it 1--> If few people are electing then every time ur candidate should win 2--> arrange books in box, if box carry weight == books weight then take another box..... find the no of box required.
design a c++ class for the chess board,provide a c++ class definition for such class(only class definition is required)
What makes a language oop?
What is inheritance in simple words?
#include
What is for loop and its syntax?
What is the fundamental idea of oop?
Why oops is important?
What is the difference between static polymorphism and dynamic polymorphism?