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

Explain selection sorting. Also write an example.

0 Answers  


What is a Default constructor?

1 Answers  


Write a program to find the reverse Fibonacci series starting from N.

0 Answers   Huawei,


Should a constructor be public or private?

0 Answers  


What is const in c++?

0 Answers  






diff between pointer and reference in c++?

1 Answers  


What is format for defining a structure?

0 Answers  


What is c++ similar to?

0 Answers  


What issue do auto_ptr objects address?

2 Answers  


Would you rather wait for quicksort, linear search, or bubble sort on a 200000 element array? (Or go to lunch...) a) Quicksort b) Linear Search c) Bubble Sort

0 Answers  


i want the NIC programmer-B model papaer pattren, iwant the all model papers?

15 Answers   NIC,


Memory is not a constraint. In a single iteration(NOTE: you can't go back), how will you find out the 10th last node/item in a linked list.

16 Answers   BNB, FDS, Goldman Sachs, Nagarro,


Categories