In which memory a class gets stored(in heap /in stack)?
And why??

Answers were Sorted based on User's Feedback



In which memory a class gets stored(in heap /in stack)? And why??..

Answer / pravin

The stack is a place in the computer memory where all the variables that are declared and initialized before runtime are stored. The heap is the section of computer memory where all the variables created or initialized at runtime are stored.
Hence,classes will be stored in heap memory.

Is This Answer Correct ?    6 Yes 3 No

In which memory a class gets stored(in heap /in stack)? And why??..

Answer / ravi.g

Usually class will get stored when the object/s are created.

Class will get sored in stack segment when the object is
created inside the functions.

When objects are created globally they will get stored in
the data segment.

Is This Answer Correct ?    2 Yes 3 No

Post New Answer

More C++ General Interview Questions

Is c++ fully object oriented?

0 Answers  


Define what is constructor?

0 Answers  


What is difference between initialization and assignment?

12 Answers   HCL, HP, Infosys,


What does new in c++ do?

0 Answers  


Differentiate between realloc() and free().

0 Answers  


Why we use #include iostream in c++?

0 Answers  


List the merits and demerits of declaring a nested class in C++?

0 Answers  


Enter n no. of element and delete value from desire position

1 Answers  


What is main function in c++ with example?

0 Answers  


What is the difference between "calloc" and "malloc"?

9 Answers   ADP,


What is math h in c++?

0 Answers  


which operator is used for performing an exponential operation a) > b) ^ c) none

0 Answers  


Categories