What are the basics of classifying different storage types,
why?

Answers were Sorted based on User's Feedback



What are the basics of classifying different storage types, why?..

Answer / sv

Automatic
External
Static
Register

Automatic is local storage applied for local variables.

External is global variable,which shall be accessed through
out the program at any modules.

Static retains its values and live till end of the program,
but not visible to all modules, hence accessible with in
the scope.

Register: In few program, where performance is high
importance we can use register storage, so that access
overhead is less.In this storage type , an varible always
uses the register for read/write.

Is This Answer Correct ?    2 Yes 0 No

What are the basics of classifying different storage types, why?..

Answer / prit

The different storage types in C++ are
Auto: all the variables declared in C++ are of the type
auto by default
The scope is limited to the loop

int temp; //is by default of type auto

Register: tels the C++ compiler to allocate some storage in
the registers.They are supposed to be faster then other
storage types.

register int var;

Only nonstatic, local variables may reside in registers,
and C++ uses the same rules for register variable scope and
initialization as it does with automatic variables

Mutable:const memebre functions or data types can be
modified using mutable keyword.

mutable int i;

static:static variable is declared as a member of a class,
then it will preserve the value for all the objects of the
class.i.e, one copy of this data variable will be shared by
all objects of the class.

static int temp;

extern : extern keyword is used to specify that the
variable is declared in a different file.Used mostly to
declare global scope

extern int num;

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

class X { private: int a; protected: X(){cout<<"X constructor was called"<<endl;} ~X(){cout<<"X destructor was called"<<endl} }; Referring to the code above, which one of the following statements regarding "X" is TRUE? a) X is an abstract class. b) Only subclasses of X may create X objects. c) Instances of X cannot be created. d) X objects can only be created using the default copy constructor. e) Only friends can create instances of X objects.

2 Answers   Quark,


What is the use of endl in c++?

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 maximum number of concurrent threads that the InnoDB plug-in can create

0 Answers  


what is the size of this class class size { public: char data1; double d; int data2; char data3; double data4; short data5; }; please explain the padding for these double variables.

9 Answers  


How the keyword struct is different from the keyword class in c++?

0 Answers  






What is the difference between method overloading and method overriding in c++?

0 Answers  


Explain the difference between new() and malloc() in c++?

0 Answers  


You're given an array containing both positive and negative integers and required to find the sub-array with the largest sum (O(N) a la KBL). Write a routine in C for the above.

4 Answers  


Define a program that reads two matrices of size 3x3 with real values from the user then prints their sum, difference and multiplication.

0 Answers   TCS,


How can you quickly find the number of elements stored in a a) static array b) dynamic array ? Why is it difficult to store linked list in an array?how can you find the nodes with repetetive data in a linked list?

0 Answers  


Give example of a pure virtual function in c++?

0 Answers  


what is C++ objects?

0 Answers  


Categories