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

A mXn matrix is given and rows and column are sorted as shown below.Write a function that search a desired entered no in the matrix .with minimum complexity 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

0 Answers  


What is the difference between a baller and a reference in C++?

0 Answers  


Describe delete operator?

0 Answers  


How to change constant values?

6 Answers   Huawei, Symphony,


Why do we use pointers in c++?

0 Answers  






Explain how a pointer to function can be declared in C++?

0 Answers  


What are the advantages of pointers?

0 Answers  


Given an array of size N in which every number is between 1 and N, determine if there are any duplicates in it. You are allowed to destroy the array if you like. [ I ended up giving about 4 or 5 different solutions for this, each supposedly better than the others ].

1 Answers  


What are guid?

0 Answers  


Inline parameters : What does the compiler do with the parameters of inline function, that can be evaluated in runtime ?

0 Answers  


write a program that reads in a file and counts the number of lines, words, and characters. Your program should ask the user to input a filename. Open the file and report an error if the file does not exist or cannot be opened for some other reason. Then read in the contents of the file and count the number of lines, words, and characters in the file. Also print additional information about the file, such as the longest and shortest words, and longest and shortest lines. For simplicity, we define a word to be one or more characters ending with white space (a space, tab, carriage return, etc.). Functions for checking the types of characters can be found in the ctype.h header file, so you want to include this header file in your program. For example, the sentence below could be all that is in a file. This sentence IT 104 is taught in C++. has 32 characters, one line, and six words. The shortest line is 32 characters. The longest line is 32 characters. The shortest word is 2 characters. The longest word is 6 characters

0 Answers  


Will the following program execute?

0 Answers  


Categories