Types of storage and scope of each type

Answers were Sorted based on User's Feedback



Types of storage and scope of each type..

Answer / mike

Types of storage class variables in C++:
Automatic.
Extern.
static.

Automatic variables are those which are local to a function
and which are created when the function is called and
destroyed when the function is exited. The memory is
allocated and deallocated on the stack as and when the
function is called and exited.

External variables are global variables and are accessible
to all the functions in the program. They exist throughout
the program.Memory is set when they have have been declared
and will remain till the end of the program.

Static variables are like external varibles which will be
declared within a function and will maintain their values
between function calls.They also exist until throughout the
program

Is This Answer Correct ?    10 Yes 0 No

Types of storage and scope of each type..

Answer / p.mathiazhagan

There four types of storage is available.
1)Automatic
2)external
3)static
4)register

The first three is explained before answer...

Register variable are not using the memory. It stored
in registers. It is mainly used to fast access then
previous storage. But, It has some limitation for declaring
the variable

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

structure contains int, char, float how it behaves for big endian and little endian?

1 Answers   BITS,


What is object in c++ wikipedia?

0 Answers  


What is the limitation of cin while taking input for character array?

0 Answers  


Out of fgets() and gets() which function is safe to use and why?

0 Answers  


Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL.

4 Answers   Webyog,






Write a program which uses Command Line Arguments

0 Answers  


What does override mean in c++?

0 Answers  


If you had the following code: int x = 23; int *y; y = &x; The instruction y++; does what?

2 Answers  


Problem 6: Area of a trapezoid can be calculated by the following formula: A=(b1 b2)×h2 where b1 and b2 are the parallel sides or the bases and h is length of height Write a C code of this program

0 Answers   Maxobiz,


check whether a no is prime or not.

3 Answers   TCS,


What about Virtual Destructor?

1 Answers   Virtusa,


Write the program for fibonacci in c++?

20 Answers   TATA, Wipro,


Categories