Generally variables are stored in heap memory. When he
variables are created in stack?

Answers were Sorted based on User's Feedback



Generally variables are stored in heap memory. When he variables are created in stack?..

Answer / vadivelt

It is wrong to say that genarally variables will be stored
in heap memmory.

Bcos Storage area always depends on the storage class of
the variable.

According to the C standard the storage will be.
1.variable with storage class 'auto' ie., local to the
function - in stack memory.
2.variable with storage class 'extern' and 'static' in data
segment.
3.variable with storage class 'register' in processor
register. But this register variable will be treated as
auto when there is no enough memory in the processor.

Is This Answer Correct ?    15 Yes 0 No

Generally variables are stored in heap memory. When he variables are created in stack?..

Answer / rohit repale

It is wrong to say that genarally variables will be stored
in heap memmory.
Bcos Storage area always depends on the storage class of
the variable.
If the variables are created by new i.e. dynamic memory is
created then it use heap memory.
static & extern variables are stored in static memory.
And other normal variables are stored in stack.

Is This Answer Correct ?    3 Yes 0 No

Generally variables are stored in heap memory. When he variables are created in stack?..

Answer / suneet

According to the C standard the storage will be.
1.variable with storage class 'auto' ie., local to the
function - in stack memory.
2.variable with storage class when 'extern' and 'static' are initialized stored in data segment otherwise found in bss.
3.variable with storage class 'register' in processor
register. But this register variable will be treated as
auto when there is no enough memory in the processor.

Is This Answer Correct ?    2 Yes 0 No

Generally variables are stored in heap memory. When he variables are created in stack?..

Answer / rahul

I am not sure about this answer but when you pass any
argument to any recursive or non-recursive function.

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More C++ General Interview Questions

What is endl c++?

0 Answers  


Name the operators that cannot be overloaded in C++?

0 Answers   Fidelity,


Give 2 examples of a code optimization?

4 Answers  


1. What does the following do: void afunction(int *x) { x=new int; *x=12; } int main() { int v=10; afunction(&v); cout<<v; } a) Outputs 12 b) Outputs 10 c) Outputs the address of v

5 Answers   Quark,


What is the difference between object-oriented programming and procedural programming?

0 Answers  






Do you need a main function in c++?

0 Answers  


What is c++ programming language?

0 Answers  


What is the function to call to turn an ascii string into a long?

0 Answers  


How can you tell what shell you are running on unix system?

0 Answers  


What are its advantages and disadvantages of multiple inheritances (virtual inheritance)?

0 Answers  


What is the function of I/O library in C++ ?

0 Answers   HCL,


What are literals in C++?

0 Answers   Wipro,


Categories