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 |
write a program to find the largest of two numbers without using for,while,switch,if else, conditional operator and do while using c++ pgmng language
Why do we use polymorphism in oops?
How long to learn object oriented programming?
The expansion of GNU
Why oops is important?
what is the difference between a package and a software?
What is encapsulation and abstraction? How are they implemented in C++?
0 Answers Agilent, ZS Associates,
What is abstraction in oop with example?
What is coupling in oops?
What is the difference between class and object?
Why static Function is used in C++?
What is the difference between abstraction and polymorphism?