answersLogoWhite

0


Best Answer

A storage class is not a class as such, it is a modifier. C++ provides several built-in storage classes: auto, register, static, extern and mutable.

The auto storage class is implied for all function local variables and it can only be used in functions. Since it is implied it is rarely used. However, with C++11, the auto keyword has an alternative use, allowing unambiguous types to be deduced without the need to explicitly declare their type. This greatly simplifies code where the type is of little importance to the reader, and is particularly useful when iterating through an STL container as it greatly simplifies and shortens the declaration of the for statement that controls the loop.

The register storage class can be used for any variable that will fit in a CPU register. Since register variables do not exist in RAM, they have no address. Declaring a register variable is not a guarantee that the variable will be stored in a register, only that it might be. Simple variables such as counters are good candidates for register variables, however your compiler should be able to automatically determine when to use a register rather than RAM for a variable.

The static storage class ensures that a variable remains in memory at all times. This does not mean the variable is accessible at all times, however, since visibility is ultimately determined by the variable's scope. However, when you modify a static variable that is in scope, it will maintain that value even when it falls from scope (static variables are never destroyed). All static variables must be initialised with a value and each time the program is run, they will default to the initial value.

Class member functions as well as variables can be declared static. Static members of a class are local to the class, rather than to an instance of the class. They are generally used to provide internal class functionality or information that is common to all instances of the class (much like global functions and variables, but scoped to the class). Public static members are also accessible outside of the class, even when no instances of the class exist.

Extern provides external linkage to a global variable that is defined in another file. This is typically used when two or more source files share the same global variable. One file defines the global while all others declare it external.

The mutable storage class is only used in classes, and allows the member to override the constness of the class. That is, when calling constant member functions, the class' mutable members can be modified while the immutable (normal) members remain constant. Mutable members are typically used internally be the class, such that the external "state" of the class can remain constant.

User Avatar

Wiki User

9y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

12y ago

Integer: int [This can store Negatives and Positives but no decimals]

Floating point:

double [This can store negatives and positives and decimals]

float [This is rarely used]

text string: "Text here"

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

Data storage has two meanings: data that is stored in working memory (RAM) and data that is stored in mass storage media (disk files, flash-drives, laser disc, tape, etc).

In C++ and most other languages, data storage usually refers to working memory where data is stored in variables and constants. The type of the variable or constant determines the type of the datum stored in the memory allocated to the variable or constant.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is data storage in c plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is storage classes in c plus plus?

AUTO EXTERN STATIC are the storage classes in c++


What is file handling in c and c plus plus or objective c?

File handling is simply the process of opening, reading, writing and closing files. Files are simply streams for input and output, or the "serialisation" of objects. In other words, reading and writing data to and from disk storage.


User defined data type in c plus plus?

Use "typedef" : both in C and C++.


What are the storage allocation in C plus plus?

They mostly deal with pointers and new operators in memory.


What are the storage devices in c?

C is your computers actual hard drive. It is where the data is stored as well as your operating system.


Can an integer data type in c plus plus stores character value?

no


What is the price of the book data structure using c and c plus plus by tanenbaum?

225 Rs. after discount........


What use of void data type in c plus plus?

doesn't return the value.


What are the two types of constant in c plus plus?

Constant data and constant functions.


Program to generate Fibonacci series using storage class in c plus plus?

i dn't know. haha


Is there anything similar between C and C plus plus with reference to data hiding?

No. Data hiding is a feature of object oriented programming. C does not support OOP, and therefore has no private member access. All members are public in C.


When c was already there why did c plus plus was developed?

c is a structured language. It has many limitations since it gives more importance to procedure rather than data..so there needed a language that keeps data secure..