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

Difference between Top down and bottom up approaches for a given project ?

14 Answers   BSNL, CSC, HCL, HP, IIT, Infosys, Siemens,


How to change constant values?

6 Answers   Huawei, Symphony,


Design a program to input a date from user in the form day/month/year (e.g. 2/6/2000) and report whether it’s a valid date or not. The program should take account of leap years. You will need to know that a leap year is a year that is exactly divisible by 4, except that century years are only leap years if they are divisible by 400.

1 Answers  


How would you use the functions sin(), pow(), sqrt()?

0 Answers  


What are the extraction and insertion operators in c++?

0 Answers  






3- Write a program to find larger and smaller of the two numbers.

4 Answers   Luminous,


What is a class template in c++?

0 Answers  


What is the Standard Template Library?

1 Answers  


Write a program that will count the number of digits in an input integer up to value MAX_VALUE (2147483647). Thus, for an input of 5837 the output should be 4 digits Make sure that your program works for the numbers 0, 1, and 10. For the number 0, the output should be 1 digit

2 Answers  


Explain pass by value and pass by reference.

0 Answers  


What happens when a function throws an exception that was not specified by an exception specification for this function?

1 Answers  


What is the meaning of c++?

0 Answers  


Categories