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 :( :-?
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / vishwa
Both are allocated in heap.
Also if any structure is declared in a function, the
function stack creates a heap from the stack. so these
structures in function allocates in heap.
| Is This Answer Correct ? | 3 Yes | 2 No |
WHAT IS THE ACTUAL DEFINATION OF OBJECT AND THE CLASS IN ONE SINGLE LINE WHICH THE INTERVIEWER WANT TO LISTEN.
difference between overloading and overridding
What is destructor in oop?
write a progra in c++ using class & object to find out wheather a given no. is prim or not.
Write an operator overloading program to write S3+=S2.
What is class in oop with example?
What is friend function?
How to calculate the age from the date of birth by using the program?
What is virtual function?where and when is it used?
What does oop mean in snapchat?
what is ns string? what is ns array?
How to improve object oriented design skills?