• Skip to main content
  • Skip to primary sidebar
  • Skip to secondary sidebar
  • Skip to footer

Computer Notes

Library
    • Computer Fundamental
    • Computer Memory
    • DBMS Tutorial
    • Operating System
    • Computer Networking
    • C Programming
    • C++ Programming
    • Java Programming
    • C# Programming
    • SQL Tutorial
    • Management Tutorial
    • Computer Graphics
    • Compiler Design
    • Style Sheet
    • JavaScript Tutorial
    • Html Tutorial
    • Wordpress Tutorial
    • Python Tutorial
    • PHP Tutorial
    • JSP Tutorial
    • AngularJS Tutorial
    • Data Structures
    • E Commerce Tutorial
    • Visual Basic
    • Structs2 Tutorial
    • Digital Electronics
    • Internet Terms
    • Servlet Tutorial
    • Software Engineering
    • Interviews Questions
    • Basic Terms
    • Troubleshooting
Menu

Header Right

Home » C++ » Classes » Storage Classes
Next →
← Prev

Storage Classes

By Dinesh Thakur

Storage Classes are used to determine in which space the value of variable will Stored. And what will be the value of variable, when we doesn’t Specify the value of variable. And In what Place we can use the value of variable. The Storage Classes Determines the Following things.

1) Variable: Where the Value of variable will be Stored. In the Memory or in the Registers. Because the Value which is Stored in the Registers will fastly Accessed, Generally value of a variables is Stored into the Memory. The Registers are near to the CPU So that value which is given by user recently is Stored into the Registers.
2) Default Value: The Storage Class also determines what will be the value of the variable, if doesn’t Specified by a user. Means default value of the user. The Default value of the variable may either a 0 or a garbage value which is specified by the Computer.
3) Scope: The Storage Classes also determines where we can use the value of the variable Means what is the Scope of the variable.

There are two Types of Variables in C++ Language

1)   Local Variable.
2)   Global or External variables

The Local Variables are those which are declared in the Main function or in the Simple Function. The variables those are declared in the Function will never be accessed by Main Function and also vice versa. So that the Local variables those are declared Within a Block and the variables are accessed in the Block only, not from outside the Function. And not in other Functions.
Global variables: The Global variables are those which are accessed by any Function whether it is a Main Function or whether in any function So that the Global variables are those which are accessed from any Function. And the Functions those are Global Scope Accessed by any Function and in any Function we Can Specify the value of variable.

There are four types of Storage Classes those are as Followings: —

1) Automatic Storage Classes: The Automatic Storage Class Specifies that

Value of Variable Will be Stored into the Memory.

Default value: if we don’t specify the value to the variable, then this will accept the Default value as a Garbage Value.
Local Scope: The variables those are declared as Automatic will have a Local Scope Means we can Access the Value only that Location, where we have declared that variable.

If we don’t Specify Any Class, then this is the default Class and this class always takes an auto Keyword.

Static Storage Class

Value of Variable Will be Stored into the Memory.

Default value: if we don’t specify the value to the variable, then this will accept the Default value as a 0.
Local Scope: The variables those are declared as Static will have a Local Scope Means we can Access the Value only that Location, where we have declared that variable.

Registers Storage Class

Value of Variable Will be Stored into the Registers rather than Memory.

Default value: if we don’t specify the value to the variable, then this will accept the Default value as a Garbage Value.
Local Scope: The variables those are declared as Register have a Local Scope Means we can Access the Value only that Location, where we have declared that variable.

External Storage Class

Value of Variable Will be Stored into the Memory.

Default value: if we don’t specify the value to the variable, then this will accept the Default value as a Garbage Value.
Global Scope: The variables those are declared as External will have a Global Scope Means we can Access the Value in any Location, means we access that variable in the Main Function or in any Function.
If we don’t Specify Any Class, then this is the default Class and this class always takes an auto Keyword.

Storage Classes are used to determine in which space the value of variable will Stored. And what will be the value of variable, when we doesn’t Specify the value of variable. And In what Place we can use the value of variable. The Storage Classes Determines the Following things

1) Variable: Where the Value of variable will be Stored. In the Memory or in the Registers. Because the Value which is Stored in the Registers will fastly Accessed, Generally value of a variables is Stored into the Memory. The Registers are near to the CPU So that value which is given by user recently is Stored into the Registers.

2) Default Value: The Storage Class also determines what will be the value of the variable, if doesn’t Specified by a user. Means default value of the user. The Default value of the variable may either a 0 or a garbage value which is specified by the Computer.

3) Scope: The Storage Classes also determines where we can use the value of the variable Means what is the Scope of the variable.

There are two Types of Variables in C++ Language

1)   Local Variable.

2)   Global or External variables

The Local Variables are those which are declared in the Main function or in the Simple Function. The variables those are declared in the Function will never be accessed by Main Function and also vice versa. So that the Local variables those are declared Within a Block and the variables are accessed in the Block only, not from outside the Function. And not in other Functions.

Global variables: The Global variables are those which are accessed by any Function whether it is a Main Function or whether in any function So that the Global variables are those which are accessed from any Function. And the Functions those are Global Scope Accessed by any Function and in any Function we Can Specify the value of variable.

There are four types of Storage Classes those are as Followings: —

1) Automatic Storage Classes: The Automatic Storage Class Specifies that

Value of Variable Will be Stored into the Memory.
Default value: if we don’t specify the value to the variable, then this will accept the Default value as a Garbage Value.
Local Scope: The variables those are declared as Automatic will have a Local Scope Means we can Access the Value only that Location, where we have declared that variable.
If we don’t Specify Any Class, then this is the default Class and this class always takes an auto Keyword.

Static Storage Class

Value of Variable Will be Stored into the Memory.
Default value: if we don’t specify the value to the variable, then this will accept the Default value as a 0.
Local Scope: The variables those are declared as Static will have a Local Scope Means we can Access the Value only that Location, where we have declared that variable.

Registers Storage Class

Value of Variable Will be Stored into the Registers rather than Memory.
Default value: if we don’t specify the value to the variable, then this will accept the Default value as a Garbage Value.
Local Scope: The variables those are declared as Register have a Local Scope Means we can Access the Value only that Location, where we have declared that variable.

External Storage Class

Value of Variable Will be Stored into the Memory.
Default value: if we don’t specify the value to the variable, then this will accept the Default value as a Garbage Value.
Global Scope: The variables those are declared as External will have a Global Scope Means we can Access the Value in any Location, means we access that variable in the Main Function or in any Function.
If we don’t Specify Any Class, then this is the default Class and this class always takes an auto Keyword.

You’ll also like:

  1. C – Storage Classes
  2. What is storage classes in C with example?
  3. Primary Storage – What is Primary storage?
  4. What is Object and Classes
  5. Difference between Structures and Classes in C++
Next →
← Prev
Like/Subscribe us for latest updates     

About Dinesh Thakur
Dinesh ThakurDinesh Thakur holds an B.C.A, MCDBA, MCSD certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps.

Dinesh Thakur is a Freelance Writer who helps different clients from all over the globe. Dinesh has written over 500+ blogs, 30+ eBooks, and 10000+ Posts for all types of clients.


For any type of query or something that you think is missing, please feel free to Contact us.


Primary Sidebar

C++ Tutorials

C++ Tutorials

  • C++ - Data Types
  • C++ - Operators Types
  • C++ - CPP Program Structure
  • C++ - Conditional Statements
  • C++ - Loop
  • C++ - do-While Loop
  • C++ - Control Statements
  • C++ - Tokens
  • C++ - Jump Statements
  • C++ - Expressions
  • C++ - Constants
  • C++ - Character Set
  • C++ - Iteration Statements
  • C++ - I/O Statements
  • C++ - String
  • C++ - Manipulators

C++ Operator

  • C++ - Input/Output Operator
  • C++ - Operator Overloading

C++ Functions

  • C++ - Functions
  • C++ - Member Functions
  • C++ - Returning Object from Function
  • C++ - Call by Value Vs Reference
  • C++ - Friend Function
  • C++ - Virtual Function
  • C++ - Inline Function
  • C++ - Static Data Members
  • C++ - Static Member Functions

C++ Array & Pointer

  • C++ - Array
  • C++ - Array of Objects
  • C++ - Arrays as Class Members
  • C++ - Vector
  • C++ - Pointer
  • C++ - 'this' Pointer

C++ Classes & Objects

  • C++ - Class
  • C++ - Program Structure With Classes
  • C++ - OOP’s
  • C++ - Objects as Function Arguments
  • C++ - Procedure Vs OOL
  • C++ - Object Vs Class
  • C++ - Creating Objects
  • C++ - Constructors
  • C++ - Copy Constructor
  • C++ - Constructor Overloading
  • C++ - Destructor
  • C++ - Polymorphism
  • C++ - Virtual Base Class
  • C++ - Encapsulation

C++ Inheritance

  • C++ - Inheritance
  • C++ - Multiple Inheritance
  • C++ - Hybrid Inheritance
  • C++ - Abstraction
  • C++ - Overloading

C++ Exception Handling

  • C++ - Exception Handling
  • C++ - Templates
  • C++ - Standard Template Library

C++ Data Structure

  • C++ - Link List

C++ Programs

  • C++ Program for Electricity Bill
  • C++ Program for Multiply Matrices
  • C++ Program for Arithmetic Operators
  • C++ Program For Matrices
  • C++ Program for Constructor
  • C++ Program Verify Number
  • C++ Program Array Of Structure
  • C++ Program to find Average Marks
  • C++ Program Add And Subtract Matrices
  • C++ Program Menu Driven
  • C++ Program To Simple Interest
  • C++ Program To Find Average
  • C++ program exit()
  • C++ Program Using Array Of Objects
  • C++ Program Private Member Function
  • C++ Program To Reverse A String
  • C++ Program to Operator Overloading

Other Links

  • C++ - PDF Version

Footer

Basic Course

  • Computer Fundamental
  • Computer Networking
  • Operating System
  • Database System
  • Computer Graphics
  • Management System
  • Software Engineering
  • Digital Electronics
  • Electronic Commerce
  • Compiler Design
  • Troubleshooting

Programming

  • Java Programming
  • Structured Query (SQL)
  • C Programming
  • C++ Programming
  • Visual Basic
  • Data Structures
  • Struts 2
  • Java Servlet
  • C# Programming
  • Basic Terms
  • Interviews

World Wide Web

  • Internet
  • Java Script
  • HTML Language
  • Cascading Style Sheet
  • Java Server Pages
  • Wordpress
  • PHP
  • Python Tutorial
  • AngularJS
  • Troubleshooting

 About Us |  Contact Us |  FAQ

Dinesh Thakur is a Technology Columinist and founder of Computer Notes.

Copyright © 2025. All Rights Reserved.

APPLY FOR ONLINE JOB IN BIGGEST CRYPTO COMPANIES
APPLY NOW