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

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

0 Answers  


What is the this pointer?

0 Answers  


why the size of an empty class is 1

4 Answers  


Is atoi safe?

0 Answers  


Profiler in projects?

2 Answers   Symphony,


Which of the following is not a valid declaration for main() a) int main() b) int main(int argc, char *argv[]) c) They both work

0 Answers  


Difference between Overloading and Overriding?

35 Answers   Appnetix Techno, GameLoft, HP, IBM, NIIT, Rohde and Schwarz,


What does it mean to declare a member function as static?

0 Answers  


What is a container class? What are the types of container classes in c++?

0 Answers  


How to reduce a final size of executable?

3 Answers  


5. Can inline functions have a recursion?

4 Answers  


Define virtual constructor.

0 Answers  


Categories