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

How would you represent an error detected during constructor of an object?

1 Answers  


Who calls main function?

0 Answers  


What is size_type?

0 Answers  


What flag means?

0 Answers  


write a corrected statement in c++ so that the statement will work properly. x = y = z + 3a;

0 Answers  






How many types of casting are there in C++? When is a dynamic cast,static_cast,reinterpret cast used?

2 Answers   CTS,


Explain what are single and multiple inheritances in c++?

0 Answers  


Given the following seqment of code containing a group of nested if instructions: y = 9; if ((x==3) || (x == 5)) y++; else if (x == 2) y *= 2; else if (x == ) y-= 7; else y = 8; if the value of x is 4 before the nested IFs are executed, what is the value of y after the nested IFs are executed?

0 Answers  


How many types of scopes are there in c++?

0 Answers  


What does return 0 do in c++?

0 Answers  


Explain the isa and hasa class relationships.

0 Answers  


List the issue that the auto_ptr object handles?

0 Answers  


Categories