Storage Classes in C++ — Volkswagen Pointer I

14 Май 2015 | Author: | Комментарии к записи Storage Classes in C++ — Volkswagen Pointer I отключены
Automobile catalog design in c

Storage Classes in C++

static

mutable

The auto Storage

The auto storage class is the storage class for all local

The example above defines two with the same storage auto can only be used functions, i.e. local

The register Storage Class

The storage class is used to local variables that be stored in a register instead of This means that the has a maximum size equal to the size (usually one word) and have the unary » applied to it (as it does not have a location).

The register should only be for variables that require access such as counters. It also be noted that ‘register’ does not mean the variable will be stored in a It means that it MIGHT be in a register depending on hardware and restrictions.

The static Storage

The static storage class the compiler to keep a local in existence during the life-time of the instead of creating and destroying it time it comes into and out of scope. Therefore, making variables static allows to maintain their values function calls.

The static modifier may also be to global variables. When is done, it causes that scope to be restricted to the file in it is declared.

In C++, when is used on a class data it causes only one copy of member to be shared by all objects of its

When the above code is and executed, it produces the following

The extern Storage Class

Automobile catalog design in c

The storage class is used to a reference of a global variable is visible to ALL the program files. you use ‘extern’ the variable cannot be as all it does is point the variable at a storage location that has previously defined.


When you have multiple and you define a global variable or which will be used in files also, then will be used in another to give reference of defined or function. Just for understanding is used to declare a global or function in another file.

The modifier is most commonly when there are two or more sharing the same global or functions as explained below.

File: main.cpp

Second support.cpp

Here, extern keyword is used to declare count in file. Now compile these two as follows:

This will write executable program, try to write and check the result as

The mutable Storage Class

The specifier applies only to objects, which are discussed in this tutorial. It allows a of an object to override constness. is, a mutable member can be modified by a member function.

Automobile catalog design in c
Automobile catalog design in c
Automobile catalog design in c
Automobile catalog design in c
Automobile catalog design in c

Interesting Articles



Смотрите также:

Other articles of the category "Pointer":

Twitter-news
Our partners
Follow us
Contact us
Our contacts

dima911@gmail.com

Born in the USSR

About this site

For all questions about advertising, please contact listed on the site.


Volkswagen all cars catalog with specifications, pictures, ratings, reviews and discusssions about cars Volkswagen.