0% found this document useful (0 votes)
4 views1 page

01 04 Storage Class

The document explains C++ storage classes, which define the lifetime and visibility of variables and functions. There are five types: Automatic, Register, Static, External, and Mutable, each with specific characteristics regarding memory allocation and accessibility. The document also includes a table summarizing the keywords, lifetime, visibility, and initial values for each storage class.

Uploaded by

ASK 011
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

01 04 Storage Class

The document explains C++ storage classes, which define the lifetime and visibility of variables and functions. There are five types: Automatic, Register, Static, External, and Mutable, each with specific characteristics regarding memory allocation and accessibility. The document also includes a table summarizing the keywords, lifetime, visibility, and initial values for each storage class.

Uploaded by

ASK 011
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

C++ Storage Classes

Storage class is used to define the lifetime and visibility of a variable and/or function
within a C++ program.

Lifetime refers to the period during which the variable remains active and visibility
refers to the module of a program in which the variable is accessible.

There are five types of storage classes, which can be used in a C++ program

1. Automatic It is the default storage class for all local variables. The auto keyword is
applied to all local variables automatically.
2. Register allocates memory in register than RAM. Its size is same of register size. It has
a faster access than other variables.

use register variable only for quick access such as in counter.

3. Static is initialized only once and exists till the end of a program. It retains its value
between multiple functions call.
4. External variable is visible to all the programs
5. Mutable

Storage Class Keyword Lifetime Visibility Initial Value

Automatic auto Function Block Local Garbage

Register register Function Block Local Garbage

Mutable mutable Class Local Garbage

External extern Whole Program Global Zero

Static static Whole Program Local Zero

You might also like