- A Brief Intro To C++ & Its History
- The Detailed History & Timeline Of C++ (With Infographic)
- Importance Of C++
- Versions Of C++ Language
- Structure Of A C++ Program
- Comparison With Other Popular Programming Languages
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What Are Variables In C++?
- Declaration & Definition Of Variables In C++
- Variable Initialization In C++
- Rules & Regulations For Naming Variables In C++ Language
- Different Types Of Variables In C++
- Different Types of Variable Initialization In C++
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What Are Primitive Data Types In C++?
- Derived Data Types In C++
- User-Defined Data Types In C++
- Abstract Data Types In C++
- Data Type Modifiers In C++
- Declaring Variables With Auto Keyword
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- Structure Of C++ Program: Components
- Segment 1: Documentation Section Of Structure Of C++ Program (With Example)
- Segment 2: Preprocessing & Namespace (Linking) Section Of CPP Program
- Segment 3: Definition Section In Structure of a C++ Program (With Examples)
- Segment 4: Main Function In Structure Of A C++ Program (With Example)
- Compilation & Execution Of C++ Programs | Step-by-Step Explanation
- Explaining Structure Of C++ Program With Suitable Example
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What is Typedef in C++?
- The Role & Applications of Typedef in C++
- Basic Syntax for typedef in C++
- How Does typedef Work in C++?
- How to Use Typedef in C++ With Examples? (Multiple Data Types)
- The Difference Between #define & Typedef in C++
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What Are Strings In C++?
- Types Of Strings In C++
- How To Declare & Initialize C-Style Strings In C++ Programs?
- How To Declare & Initialize Strings In C++ Using String Keyword?
- List Of String Functions In C++
- Operations On Strings Using String Functions In C++
- Concatenation Of Strings In C++
- How To Convert Int To Strings In C++
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What Is String Concatenation In C++?
- How To Concatenate Two Strings In C++ Using The ‘+' Operator?
- String Concatenation Using The strcat( ) Function
- Concatenation Of Two Strings In C++ Using Loops
- String Concatenation Using The append() Function
- C++ String Concatenation Using The Inheritance Of Class
- Concatenate Two Strings In C++ With The Friend and strcat() Functions
- Why Do We Need To Concatenate Two Strings?
- How To Reverse Concatenation Of Strings In C++?
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What Is Find In String C++?
- What Is A Substring?
- How To Find A Substring In A String In C++?
- How To Find A Character In String C++?
- Find All Substrings From A Given String In C++
- Index Substring In String In C++ From A Specific Start To A Specific Length
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What Are Pointers In C++?
- Pointer Declaration In C++
- How To Initialize And Use Pointers In C++?
- Different Types Of Pointers In C++
- References & Pointers In C++
- Arrays And Pointers In C++
- String Literals & Pointers In C++
- Pointers To Pointers In C++ (Double Pointers)
- Arithmetic Operation On Pointers In C++
- Advantages Of Pointers In C++
- Some Common Mistakes To Avoid With Pointers In Cpp
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- Understanding Pointers In C++
- What Is Pointer To Object In C++?
- Declaration And Use Of Object Pointers In C++
- Advantages Of Pointer To Object In C++
- Pointer To Objects In C++ With Arrow Operator
- An Array Of Objects Using Pointers In C++
- Base Class Pointer For Derived Class Object In C++
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What Is 'This' Pointer In C++?
- Defining ‘this’ Pointer In C++
- Example Of 'this' Pointer In C++
- Describing The Constness Of 'this' Pointer In C++
- Important Uses Of 'this' Pointer In C++
- Method Chaining Using 'this' Pointer In C++
- C++ Programs To Show Application Of 'This' Pointer
- How To Delete The ‘this’ Pointer In C++?
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What is Reference?
- What is Pointer?
- Comparison Table Of C++ Pointer Vs. Reference
- Differences Between Reference And Pointer: A Detailed Explanation
- Why Are References Less Powerful Than Pointers?
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- How To Declare A 2D Array In C++?
- C++ Multi-Dimensional Arrays
- Ways To Initialize A 2D Array In C++
- Methods To Dynamically Allocate A 2D Array In C++
- Accessing/ Referencing Two-Dimensional Array Elements
- How To Initialize A Two-Dimensional Integer Array In C++?
- How To Initialize A Two-Dimensional Character Array?
- How To Enter Data In Two-Dimensional Array In C++?
- Conclusion
- Frequently Asked Questions
- What Are Arrays Of Strings In C++?
- Different Ways To Create String Arrays In C++
- How To Access The Elements Of A String Array In C++?
- How To Convert Char Array To String?
- Conclusion
- Frequently Asked Questions
- What is Memory Allocation in C++ & Why Do We Need It?
- How Does Dynamic Memory Allocation Work?
- The new Operator in C++
- The delete Operator in C++
- Dynamic Memory Allocation in C++ | Arrays
- Did You Know: Companies That Ask About Dynamic Memory Allocation
- Dynamic Memory Allocation in C++ | Objects
- Deallocation of Dynamic Memory in C++
- malloc(), calloc(), and free() Functions in C/C++
- Applications of Dynamic Memory Allocation in C++
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What Is A Substring In C++ (Substr C++)?
- Example for substr() in C++ | Finding Substring Using Positive and Negative Indices
- Understanding substr() Basics with Examples
- Use Cases/ Examples of substr() in C++
- How to Get a Substring Before a Character Using substr() in C++?
- Use substr() in C++ to Print all Substrings of a Given String
- Print Sum of all Substrings of a String Representing a Number
- Minimum Value of all Substrings of a String Representing a Number
- Maximum Value of all Substrings of a String Representing a Number
- Points To Remember For Substr In C++
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What Is Operator In C++?
- Types Of Operators In C++ With Examples
- What Are Arithmetic Operators In C++?
- What Are Assignment Operators In C++?
- What Are Relational Operators In C++?
- What Are Logical Operators In C++?
- What Are Bitwise Operators In C++?
- What Is Ternary/ Conditional Operator In C++?
- Miscellaneous Operators In C++
- Precedence & Associativity Of Operators In C++
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What Is The New Operator In C++?
- Example To Understand New Operator In C++
- The Grammar Elements Of The New Operator In C++
- Storage Space Allocation
- How Does The C++ New Operator Works?
- What Happens When Enough Memory In The Program Is Not Available?
- Initializing Objects Allocated With New Operator In C++
- Lifetime Of Objects Allocated With The New Operator In C++
- What Is The Delete Operator In C++?
- Difference Between New And Delete Operator In C++
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- Types Of Overloading In C++
- What Is Operator Overloading In C++?
- How To Overload An Operator In C++?
- Overloadable & Non-overloadable Operators In C++
- Unary Operator Overloading In C++
- Binary Operator Overloading In C++
- Special Operator Overloading In C++
- Rules For Operator Overloading In C++
- Advantages And Disadvantages Of Operator Overloading In C++
- Function Overloading In C++
- What Is the Difference Between Operator Functions and Normal Functions?
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What Are Operators In C++?
- Introduction To Logical Operators In C++
- Types Of Logical Operators In C++ With Example Program
- Logical AND (&&) Operator In C++
- Logical NOT(!) Operator In C++
- Logical Operator Precedence And Associativity In C++
- Relation Between Conditional Statements And Logical Operators In C++
- C++ Relational Operators
- Conclusion
- Frequently Asked Important Interview Questions:
- Test Your Skills: Quiz Time
- Different Type Of C++ Bitwise Operators
- C++ Bitwise AND Operator
- C++ Bitwise OR Operator
- C++ Bitwise XOR Operator
- Bitwise Left Shift Operator In C++
- Bitwise Right Shift Operator In C++
- Bitwise NOT Operator
- What Is The Meaning Of Set Bit In C++?
- What Does Clear Bit Mean?
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- Types of Comments in C++
- Single Line Comment In C++
- Multi-Line Comment In C++
- How Do Compilers Process Comments In C++?
- C- Style Comments In C++
- How To Use Comment In C++ For Debugging Purposes?
- When To Use Comments While Writing Codes?
- Why Do We Use Comments In Codes?
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What Are Storage Classes In Cpp?
- What Is The Scope Of Variables?
- What Are Lifetime And Visibility Of Variables In C++?
- Types of Storage Classes in C++
- Automatic Storage Class In C++
- Register Storage Class In C++
- Static Storage Class In C++
- External Storage Class In C++
- Mutable Storage Class In C++
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- Decision Making Statements In C++
- Types Of Conditional Statements In C++
- If-Else Statement In C++
- If-Else-If Ladder Statement In C++
- Nested If Statements In C++
- Alternatives To Conditional If-Else In C++
- Switch Case Statement In C++
- Jump Statements & If-Else In C++
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What Is A Switch Statement/ Switch Case In C++?
- Rules Of Switch Case In C++
- How Does Switch Case In C++ Work?
- The break Keyword In Switch Case C++
- The default Keyword In C++ Switch Case
- Switch Case Without Break And Default
- Advantages & Disadvantages of C++ Switch Case
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What Is A For Loop In C++?
- Syntax Of For Loop In C++
- How Does A For Loop In C++ Work?
- Examples Of For Loop Program In C++
- Ranged Based For Loop In C++
- Nested For Loop In C++
- Infinite For Loop In C++
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What Is A While Loop In C++?
- Parts Of The While Loop In C++
- C++ While Loop Program Example
- How Does A While Loop In C++ Work?
- What Is Pre-checking Process Or Entry-controlled Loop?
- When Are While Loops In C++ Useful?
- Example C++ While Loop Program
- What Are Nested While Loops In C++?
- Infinite While Loop In C++
- Alternatives To While Loop In C++
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What Are Loops & Its Types In C++?
- What Is A Do-While Loop In C++?
- Do-While Loop Example In C++ To Print Numbers
- How Does A Do-While Loop In C++ Work?
- Various Components Of The Do-While Loop In C++
- Example 2: Adding User-Input Positive Numbers With Do-While Loop
- C++ Nested Do-While Loop
- C++ Infinitive Do-while Loop
- What is the Difference Between While Loop and Do While Loop in C++?
- When To Use A Do-While Loop?
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What are 2D Vectors in C++?
- How to Declare 2D Vectors in C++
- How to Initialize a 2D Vector in C++?
- Creating a 2D Vector in C++ with User Input for Column & Row Size
- Methods for Traversing 2D Vectors in C++
- Interview Spotlight: 2D Vectors in FAANG Interviews
- Printing 2D Vector in C++ Using Nested Loops
- Example C++ Programs for Creating 2D Vectors
- How to Access & Modify 2D Vector Elements in C++?
- Adding Elements to 2D Vector Using push_back() Function
- Removing Elements from Vector in C++ Using pop_back() Function
- Did You Know? Real-World Outage: Crash Cause Linked to 2D Vector Usage
- Advantages of 2D Vectors Over Traditional Arrays
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- How To Print A Vector In C++ By Overloading Left Shift (<<) Operator?
- How To Print Vector In C++ Using Range-Based For-Loop?
- Print Vector In C++ With Comma Separator
- Printing Vector In C++ Using Indices (Square Brackets/ Double Brackets & at() Function)
- How To Print A Vector In C++ Using std::copy?
- How To Print A Vector In C++ Using for_each() Function?
- Printing C++ Vector Using The Lambda Function
- How To Print Vector In C++ Using Iterators?
- Conclusion
- Frequently Asked Questions
- Definition Of C++ Find In Vector
- Using The std::find() Function
- How Does find() In Vector C++ Function Work?
- Finding An Element By Custom Comparator Using std::find_if() Function
- Use std::find_if() With std::distance()
- Element Find In Vector C++ Using For Loop
- Using The find_if_not Function
- Find Elements With The Linear Search Approach
- Conclusion
- Frequently Asked Questions
- What Is Sort() Function In C++?
- Sort() Function In C++ From Standard Template Library
- Exceptions Of Sort() Function/ Algorithm In C++
- The Stable Sort() Function In C++
- Partial Sort() Function In C++
- Sorting In Ascending Order With Sort() Function In C++
- Sorting In Descending Order With Sort Function In C++
- Sorting In Desired Order With Custom Comparator Function & Sort Function In C++
- Sorting Elements In Desired Order Using Lambda Expression & Sort Function In C++
- Types of Sorting Algorithms In C++
- Advanced Sorting Algorithms In C++
- How Does the Sort() Function Algorithm Work In C++?
- Conclusion
- Frequently Asked Questions
- What Is Function Overloading In C++?
- Ways Of Function Overloading In C++
- Function Overloading In C++ Using Different Types Of Parameters
- Function Overloading In C++ With Different Number Of Parameters
- Function Overloading In C++ Using Different Sequence Of Parameters
- How Does Function Overloading In C++ Work?
- Rules Of Function Overloading In C++
- Why Is Function Overloading Used?
- Types Of Function Overloading Based On Time Of Resolution
- Causes Of Function Overloading In C++
- Ambiguity & Function Overloading In C++
- Advantages Of Function Overloading In C++
- Disadvantages Of Function Overloading In C++
- Operator Overloading In C++
- Function Overriding In C++
- Difference Between Function Overriding & Function Overloading In C++
- Conclusion
- Frequently Asked Questions
- What Is An Inline Function In C++?
- How To Define The Inline Function In C++?
- How Does Inline Function In C++ Work?
- The Need For An Inline Function In C++
- Can The Compiler Ignore/ Reject Inline Function In C++ Programs?
- Normal Function Vs. Inline Function In C++
- Classes & Inline Function In C++
- Understanding Inline, __inline, And __forceinline Functions In C++
- When To Use An Inline Function In C++?
- Advantages Of Inline Function In C++
- Disadvantages Of Inline Function In C++
- Why Not Use Macros Instead Of An Inline Function In C++?
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What Is Static Data Member In C++?
- How To Declare Static Data Members In C++?
- How To Initialize/ Define Static Data Member In C++?
- Ways To Access A Static Data Member In C++
- What Are Static Member Functions In C++?
- Example Of Member Function & Static Data Member In C++
- Practical Applications Of Static Data Member In C++
- Conclusion
- Frequently Asked Questions
- What Is A Constant In C++?
- Ways To Define Constant In C++
- What Are Literals In C++?
- Pointer To A Constant In C++
- Constant Function Arguments In C++
- Constant Member Function Of Class In C++
- Constant Data Members In C++
- Object Constant In C++
- Conclusion
- Frequently Asked Questions(FAQ)
- What is the Friend Function in C++?
- Declaration of Friend Function in C++ with Example
- Characteristics of Friend Function in C++
- Types/ Ways to Implement Friend Function in C++
- Global Friend Function in C++ (Global Function as Friend Function )
- Member Function of Another Class as a Friend Function in C++
- Function Overloading Using Friend Function in C++
- Advantages & Disadvantages of Friend Function in C++
- Interview Spotlight: Friend Functions in Cognizant Interview
- What is a C++ Friend Class?
- A Function Friendly to Multiple Classes
- C++ Friend Class vs. Friend Function in C++
- Some Important Points About Friend Functions and Classes in C++
- Conclusion
- Frequently Asked Questions
- What Is Function Overriding In C++?
- The Working Mechanism Of Function Overriding In C++
- Real-Life Example Of Function Overriding In C++
- Accessing Overriding Function In C++
- Accessing Overridden Function In C++
- Function Call Binding With Class Objects | Function Overriding In C++
- Function Call Binding With Base Class Pointers | Function Overriding In C++
- Advantages Of Function Overriding In C++
- Variations In Function Overriding In C++
- Function Overloading In C++
- Function Overloading Vs Function Overriding In C++
- Conclusion
- Frequently Asked Questions
- Errors In C++
- What Is Exception Handling In C++?
- Exception Handling In C++ Program Example
- C++ Exception Handling: Basic Keywords
- The Need For C++ Exception Handling
- C++ Standard Exceptions
- C++ Exception Classes
- User-Defined Exceptions In C++
- Advantages & Disadvantages Of C++ Exception Handling
- Conclusion
- Frequently Asked Questions
- What Are Templates In C++ & How Do They Work?
- Types Of Templates In C++
- What Are Function Templates In C++?
- C++ Template Functions With Multiple Parameters
- C++ Template Function Overloading
- What Are Class Templates In C++?
- Defining A Class Member Outside C++ Template Class
- C++ Template Class With Multiple Parameters
- What Is C++ Template Specialization?
- How To Specify Default Arguments For Templates In C++?
- Advantages Of C++ Templates
- Disadvantages Of C++ Templates
- Difference Between Function Overloading And Templates In C++
- Conclusion
- Frequently Asked Questions
- Structure
- Structure Declaration
- Initialization of Structure
- Copying and Comparing Structures
- Array of Structures
- Nested Structures
- Pointer to a Structure
- Structure as Function Argument
- Self Referential Structures
- Class
- Object Declaration
- Accessing Class Members
- Similarities between Structure and Class
- Which One Should You Choose?
- Key Difference Between a Structure and Class
- Summing Up
- Test Your Skills: Quiz Time
- What Is A Class And Object In C++?
- What Is An Object In C++?
- How To Create A Class & Object In C++? With Example
- Interview Spotlight: Classes & Objects In Adobe & Pixar Interviews
- Access Modifiers & Class/ Object In C++
- Member Functions Of A Class In C++
- How To Access Data Members And Member Functions?
- Significance Of Class & Object In C++
- Did You Know? The Concept of Classes & Object Powers Major Apps
- What Are Constructors In C++ & Its Types?
- What Is A Destructor Of Class In C++?
- An Array Of Objects In C++
- Object In C++ As Function Arguments
- The this (->) Pointer & Classes In C++
- The Need For Semicolons At The End Of A Class In C++
- Conclusion
- Frequently Asked Questions
- What Are Static Members In C++?
- Static Member Functions in C++
- Ways To Call Static Member Function In C++
- Properties Of Static Member Function In C++
- Need Of Static Member Functions In C++
- Regular Member Function Vs. Static Member Function In C++
- Limitations Of Static Member Functions In C++
- Conclusion
- Frequently Asked Questions
- What Is Constructor In C++?
- Characteristics Of A Constructor In C++
- Types Of Constructors In C++
- Default Constructor In C++
- Parameterized Constructor In C++
- Copy Constructor In C++
- Dynamic Constructor In C++
- Benefits Of Using Constructor In C++
- How Does Constructor In C++ Differ From Normal Member Function?
- Constructor Overloading In C++
- Constructor For Array Of Objects In C++
- Constructor In C++ With Default Arguments
- Initializer List For Constructor In C++
- Dynamic Initialization Using Constructor In C++
- Conclusion
- Frequently Asked Questions
- What Is A Constructor In C++?
- What Is Constructor Overloading In C++?
- Dеclaration Of Constructor Ovеrloading In C++
- Condition For Constructor Overloading In C++
- How Constructor Ovеrloading In C++ Works?
- Examples Of Constructor Overloading In C++
- Lеgal & Illеgal Constructor Ovеrloading In C++
- Types Of Constructors In C++
- Characteristics Of Constructors In C++
- Advantage Of Constructor Overloading In C++
- Disadvantage Of Constructor Overloading In C++
- Conclusion
- Frеquеntly Askеd Quеstions
- What Is A Destructor In C++?
- Rules For Defining A Destructor In C++
- When Is A Destructor in C++ Called?
- Order Of Destruction In C++
- Default Destructor & User-Defined Destructor In C++
- Virtual Destructor In C++
- Pure Virtual Destructor In C++
- Key Properties Of Destructor In C++ You Must Know
- Explicit Destructor Calls In C++
- Destructor Overloading In C++
- Difference Between Normal Member Function & Destructor In C++
- Important Uses Of Destructor In C++
- Conclusion
- Frequently Asked Questions
- What Is A Constructor In C++?
- What Is A Destructor In C++?
- Difference Between Constructor And Destructor In C++
- Constructor In C++ | A Brief Explanation
- Destructor In C++ | A Brief Explanation
- Difference Between Constructor And Destructor In C++ Explained
- Order Of Calling Constructor And Destructor In C++ Classes
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What Is Type Conversion In C++?
- What Is Type Casting In C++?
- Types Of Type Conversion In C++
- Implicit Type Conversion (Coercion) In C++
- Explicit Type Conversion (Casting) In C++
- Advantages Of Type Conversion In C++
- Disadvantages Of Type Conversion In C++
- Difference Between Type Casting & Type Conversion In C++
- Application Of Type Casting In C++
- Conclusion
- Frequently Asked Questions
- What Is A Copy Constructor In C++?
- Characteristics Of Copy Constructors In C++
- Types Of Copy Constructors In C++
- When Do We Call The Copy Constructor In C++?
- When Is A User-Defined Copy Constructor Needed In C++?
- Types Of Constructor Copies In C++
- Can We Make The Copy Constructor In C++ Private?
- Assignment Operator Vs Copy Constructor In C++
- Example Of Class Where A Copy Constructor Is Essential
- Uses Of Copy Constructors In C++
- Conclusion
- Frequently Asked Questions
- Why Do You Need Object-Oriented Programming (OOP) In C++?
- OOPs Concepts In C++ With Examples
- The Class OOPs Concept In C++
- The Object OOPs Concept In C++
- The Inheritance OOPs Concept In C++
- Polymorphism OOPs Concept In C++
- Abstraction OOPs Concept In C++
- Encapsulation OOPs Concept In C++
- Other Features Of OOPs In C++
- Benefits Of OOP In C++ Over Procedural-Oriented Programming
- Disadvantages Of OOPS Concept In C++
- Why Is C++ A Partial OOP Language?
- Conclusion
- Frequently Asked Questions
- Introduction To Abstraction In C++
- Types Of Abstraction In C++
- What Is Data Abstraction In C++?
- Understanding Data Abstraction In C++ Using Real Life Example
- Ways Of Achieving Data Abstraction In C++
- What Is An Abstract Class?
- Advantages Of Data Abstraction In C++
- Use Cases Of Data Abstraction In C++
- Encapsulation Vs. Abstraction In C++
- Conclusion
- Frequently Asked Questions
- What Is Encapsulation In C++?
- How Does Encapsulation Work In C++?
- Types Of Encapsulation In C++
- Why Do We Need Encapsulation In C++?
- Implementation Of Encapsulation In C++
- Access Specifiers & Encapsulation In C++
- Role Of Access Specifiers In Encapsulation In C++
- Member Functions & Encapsulation In C++
- Data Hiding & Encapsulation In C++
- Features Of Encapsulation In C++
- Advantages & Disadvantages Of Encapsulation In C++
- Difference Between Abstraction and Encapsulation In C++
- Conclusion
- Frequently Asked Questions
- What Is Inheritance In C++?
- What Are Child And Parent Classes?
- Syntax And Structure Of Inheritance In C++
- Implementing Inheritance In C++
- Importance Of Inheritance In C++
- Types Of Inheritance In C++
- Visibility Modes Of Inheritance In C++
- Access Modifiers & Inheritance In C++
- How To Make A Private Member Inheritable?
- Member Function Overriding In Inheritance In C++
- The Diamond Problem | Inheritance In C++ & Ambiguity
- Ways To Avoid Ambiguity Inheritance In C++
- Why & When To Use Inheritance In C++?
- Advantages Of Inheritance In C++
- The Disadvantages Of Inheritance In C++
- Conclusion
- Frequently Asked Questions
- What Is Hybrid Inheritance In C++?
- Importance Of Hybrid Inheritance In Object Oriented Programming
- Example Of Hybrid Inheritance In C++: Using Single and Multiple Inheritance
- Example Of Hybrid Inheritance In C++: Using Multilevel and Hierarchical Inheritance
- Real-World Applications Of Hybrid Inheritance In C++
- Conclusion
- Frequently Asked Questions
- What Is Multiple Inheritance In C++?
- Examples Of Multiple Inheritance In C++
- Ambiguity Problem In Multiple Inheritance In C++
- Ambiguity Resolution In Multiple Inheritance In C++
- The Diamond Problem In Multiple Inheritance In C++
- Visibility Modes In Multiple Inheritance In C++
- Advantages & Disadvantages Of Multiple Inheritance In C++
- Multiple Inheritance Vs. Multilevel Inheritance In C++
- Conclusion
- Frequently Asked Questions
- What Is Multilevel Inheritance In C++?
- Block Diagram For Multilevel Inheritance In C++
- Multilevel Inheritance In C++ Example
- Constructor & Multilevel Inheritance In C++
- Use Cases Of Multilevel Inheritance In C++
- Multiple Vs Multilevel Inheritance In C++
- Advantages & Disadvantages Of Multilevel Inheritance In C++
- Conclusion
- Frequently Asked Questions
- What Is Hierarchical Inheritance In C++?
- Example 1: Hierarchical Inheritance In C++
- Example 2: Hierarchical Inheritance In C++
- Impact of Visibility Modes In Hierarchical Inheritance In C++
- Advantages And Disadvantages Of Hierarchical Inheritance In C++
- Use Cases Of Hierarchical Inheritance In C++
- Conclusion
- Frequently Asked Questions
- What Are Access Specifiers In C++?
- Types Of Access Specifiers In C++
- Public Access Specifiers In C++
- Private Access Specifier In C++
- Protected Access Specifier In C++
- The Need For Access Specifiers In C++
- Combined Example For All Access Specifiers In C++
- Best Practices For Using Access Specifiers In C++
- Why Can't Private Members Be Accessed From Outside A Class?
- Conclusion
- Frequently Asked Questions
- What Is The Diamond Problem In C++?
- Example Of The Diamond Problem In C++
- Resolution Of The Diamond Problem In C++
- Virtual Inheritance To Resolve Diamond Problem In C++
- Scope Resolution Operator To Resolve Diamond Problem In C++
- Conclusion
- Frequently Asked Questions
What Are Storage Classes In C++? A Detailed Guide With Examples
Storage classes tell us about the scope of variables as well as their lifespan and visibility. These functionalities help us to find the existence of a particular variable/function during the execution of a program. In C++, there are five storage classes, namely automatic, register, static, extern, and mutable.
In this article, we will look at storage classes, lifetime, visibility, and scope of variables, and different types of storage classes in C++ with their syntax and uses. We will see various examples along with the explanation to have a better understanding of the topic. So, let’s get started!
What Are Storage Classes In Cpp?
Storage classes in C++ programming language are used for variables or functions in a program to know about their scope, lifetime, visibility, and initial values. These functionalities help us to find the existence of a particular variable/function during the execution of a program.
The general syntax for defining C++ storage classes for a variable is as follows:
storage_class variable_data_type variable_name;
Here,
- storage_class: denotes the type of storage class used.
- variable_data_type: denotes the data type of a variable.
- variable_name: denotes the name of the variable.
Below are some examples of these storage classes:
auto int a = 5;
register char c = 'A';
static int count = 0;
As we have mentioned before, there are five types of storage classes in C++, and we will discuss each of these in the sections ahead.

What Is The Scope Of Variables?
The scope of a variable refers to a particular area in the program where the respective variable is declared, used, and can be modified. A variable can have different scopes ranging from a function to the entire program depending upon its type. The concept of storage classes is what defines the scope of a variable, and it also determines the lifetime and visibility of a variable.
Variables can be divided into various types depending on the storage class in C++. They are:
- Global Variables- They are declared at the beginning of the program before all other functions. Their scope is the entire program length and can be accessed from any function.
- Local variables- Their scope is limited to the function in which they are declared. It cannot be accessed outside that function or in any other part of the program.
- Static Variables- The scope of a static variable is the same as that of a local variable. Although the memory is allocated for the variable during the whole program until the program ends and memory deallocates.
- Register Variables- The scope of a register variable is only in the parent block in which it is declared. As soon as the function ends, the lifetime of the register variable in the current code block also comes to an end.
- Thread local variables- The scope of these variables depends on the creation of the thread. Whenever a thread is created, variables are also created, and similarly, the variable destroys as soon as the threads are destroyed.
What Are Lifetime And Visibility Of Variables In C++?
The lifetime of a variable in C++ refers to the time period during which the variable occupies some space in the memory and can be accessed in a function or anywhere else in the program. Some variables' lifetime is limited to a function, whereas others have a lifetime in the whole of the program.
The visibility of a variable in C++ refers to a region where a variable is accessible (or not). For example, a variable could be declared in a method, and hence it will be visible only in that variable and not anywhere else in the program. Although, a variable declared as global has its visibility in the entire program.
Types of Storage Classes in C++
In this section, we will have a look at the five major types of storage classes in C++ with the help of examples.

Automatic Storage Class In C++
The automatic storage class is the default storage class for all local variables. It is declared and can only be accessed within a particular function/method.
- In case there's no keyword specified to an automatic storage variable, it automatically gets assigned with the auto keyword.
- As per the C++11 standards, the auto keyword is used for the automatic deduction of datatype in C++.
- In this way, the compiler saves running time as it automatically predicts the data type of a variable. Even though the compilation time increases but the access time of the program does not get affected.
- The lifetime of an auto variable is limited to a function, and it cannot be accessed outside it. As soon as the function completes its execution, the automatic variables are destroyed because of its limited scope.
- We have to make use of pointer variables to access it faster outside a function in which it is not declared. The pointer points to that area in memory where the variables are stored.
- Its visibility is similar to that of a local variable. And the initial values of automatic storage classes are always garbage values.
Syntax:
auto datatype variable_name [= value];
Here,
- auto: is the storage class.
- datatype: denotes the data type of a variable.
- variable_name: denotes the name of the variable.
- value: initial garbage value.
Code Example:
CODE SNIPPET IS HERE
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnZvaWQgYXV0b21hdGljU3RvcmFnZUNsYXNzKCl7CgphdXRvIG1hcmtzPSA0OTU7CgphdXRvIGdwYSA9IDkuNTsKCmF1dG8gcmVtYXJrID0gIllvdSBhcmUgVW5zdG9wcGFibGUiOwoKY291dCA8PCAiTWFya3M9IiA8PCBtYXJrczsKCmNvdXQgPDwgIlxuIiA8PCAiZ3BhPSIgPDwgZ3BhOwoKY291dCA8PCAiXG4iIDw8ICJSZW1hcms9IiA8PCByZW1hcms7IH0KCmludCBtYWluKCl7Cgpjb3V0IDw8ICJBdXRvbWF0aWMgU3RvcmFnZSBDbGFzcyBcbiI7CgphdXRvbWF0aWNTdG9yYWdlQ2xhc3MoKTsKCnJldHVybiAwOyB9
Output:
Automatic Storage Class
Marks=495
gpa=9.5
Remark=You are Unstoppable
Explanation:
The above code snippets begins with the inclusion of iostream file and namespace std. Then,
- We define an automatic storage class with three different variables- marks, gpa, and remark as input. The data type for these variables is from the automatic storage class.
- The values assigned to the three variables are 495, 9.5, and You are Unstoppable, respectively.
- We then use the cout statement to print the values of three variables.
- In the main function, we again use the cout statement to print the phrase 'Automatic Storage Class' along with the new line specifier to move to the nest line in the output window.
Note: The program demonstrates how automatic storage classes work and the way in which they are declared inside a function. We can notice here that the scope of the variables is limited to that function, and we need to invoke the function to print its actual value.
Register Storage Class In C++
The register storage class is used for register variables when we want them to be stored in a free register instead of being stored in memory. Unlike the automatic storage class, these variables get stored in a free register, and in case no register is free at some moment, the variables get stored in the memory itself.
- We use the keyword register for storing variables under this storage class.
- As the variables are stored in a register, the operation is much faster as compared to the variables stored in memory as they utilize CPU registers.
- Register storage class is usually used for variables that need to be accessed regularly in a program, thereby increasing the program execution speed.
- The lifetime of a register variable is limited to a function, and it cannot be accessed outside it.
- As soon as the function completes its execution, the automatic variables are destroyed because of its limited scope.
- The addresses of such a register cannot even be obtained using pointers like auto storage class. Its visibility is similar to that of a local variable. The initial values of register storage classes are always garbage values.
Syntax:
register datatype variable_name [= value];
Here,
- register is the keyword for the storage class.
- datatype refers to the type of the variable.
- variable_name denotes the name of the variable.
- value refers to the initial garbage value.
Code Example:
CODE SNIPPET IS HERE
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwp2b2lkIHJlZ2lzdGVyU3RvcmFnZUNsYXNzKCl7CnJlZ2lzdGVyIGNoYXIgYT0nVSc7CmNvdXQgPDwgIlZhbHVlIG9mIGEgZGVjbGFyZWQgYXMgcmVnaXN0ZXIgc3RvcmFnZSBjbGFzczogIiA8PCBhO30KaW50IG1haW4oKXsKY291dCA8PCAiUmVnaXN0ZXIgU3RvcmFnZSBDbGFzcyBcbiI7CnJlZ2lzdGVyU3RvcmFnZUNsYXNzKCk7CnJldHVybiAwOwp9
Output:
Register Storage Class
Value of a declared as register storage class: U
Explanation:
In the C++ program above we first include the iostream file and the namespace std.
- Then we define the register storage class and a variable of the character datatype as input from the class.
- We intialise the variable with U and use the out statement to print the 'Value of a declared as register storage class'.
- In the main() function, we once again use the cout statement to print 'Register storage class'.
Note: The program simply demonstrates how register storage classes work and the way in which they are declared inside a function. We can notice here that the scope of the variables is limited to that function, and we need to invoke the function to print its actual value.
Static Storage Class In C++
The static storage class is used to declare static storage class variables, which retain their value even outside the function in which it is declared. We use the static keyword to declare variables in this class.
- The memory location for such variables remains until the end of the program. They are hence initialized only once, and no new memory is allocated.
- Global static storage class variables have their block scope as the entire program.
- In C++, whenever we use a static variable on a class data member, only a single copy of that data member is shared by all objects in the entire class.
- These static variables are most popularly used while writing programs in C++.
- The lifetime of a variable's static is the whole program, and it can be accessed anywhere in the program.
- The variable is destroyed only after the completion of the program in the case of the static storage classes.
- Its visibility is similar to that of a local variable. And the initial values of static storage classes are set to be 0.
Syntax:
static datatype variable_name [= value];
Here,
- static is the keyword for the storage class.
- datatype denotes the type of a variable.
- variable_name refers to the name you want to give to the respective variable.
- value refers to the initial value, which here is 0.
Code Example:
CODE SNIPPET IS HERE
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBzdGF0aWNWYXIoKXsKCmNvdXQgPDwgIlN0YXRpYyBWYXJpYWJsZTogIjsKCnN0YXRpYyBpbnQgZXZlbiA9IDA7CgpldmVuKys7CgpyZXR1cm4gZXZlbjt9CgppbnQgbm9uU3RhdGljVmFyKCkgewoKY291dCA8PCAiTm9uLVN0YXRpYyBWYXJpYWJsZTogIjsKCmludCBvZGQgPSAwOwoKb2RkKys7CgpyZXR1cm4gb2RkO30KCmludCBtYWluKCl7Cgpjb3V0IDw8ICJTdGF0aWMgU3RvcmFnZSBDbGFzcyBcbiI7Cgpjb3V0IDw8IHN0YXRpY1ZhcigpIDw8ICJcbiI7Cgpjb3V0IDw8IHN0YXRpY1ZhcigpIDw8ICJcbiI7Cgpjb3V0IDw8IG5vblN0YXRpY1ZhcigpIDw8ICJcbiI7Cgpjb3V0IDw8IG5vblN0YXRpY1ZhcigpIDw8ICJcbiI7CgpyZXR1cm4gMDsKCn0=
Output-
Static Storage Class
Static Variable: 1
Static Variable: 2
Non-Static Variable: 1
Non-Static Variable: 1
Explanation:
In the code example,
- We make use of two types of variables that are static variables (i.e., they retain their value) and non-static variables (that don't retain value).
- The program simply demonstrates how static variables retain their value even outside the function in which they are declared.
- We can notice here that the scope of the static variables are limited to that function, but the memory location remains until the end of the program.
Check this out- Boosting Career Opportunities For Engineers Through E-School Competitions
External Storage Class In C++
The extern storage class is used to declare external variables, which are defined somewhere else and not in the function where it is used. We use the extern keyword for variable declaration.
- The external storage class variables are like global variables that can be accessed anywhere in the program.
- A global variable can be made an external variable by using the extern keyword before its declaration in a separate file.
- The main objective of using extern variables is that no new variable needs to be initialized. This is because the global variable itself can be accessed across several different program files in the case of large executable programs with external linkage.
- The lifetime of an external variable is the whole program, as it can be accessed anywhere in the program.
- This means that the variable is destroyed only after the completion/ execution of the program.
- The visibility of external variables is similar to that of a global variable and can be accessed throughout the file. The initial values of extern storage classes are set to 0.
Syntax:
extern datatype variable_name;
Here,
- extern is the storage location class.
- datatype denotes the data type of a variable.
- variable_name denotes the name of the variable.
C++ Program Example:
CODE SNIPPET IS HERE
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmZsb2F0IGE7Cgp2b2lkIGV4dGVybmFsU3RvcmFnZUNsYXNzKCl7CgpleHRlcm4gZmxvYXQgYTsKCmNvdXQgPDwgIlZhbHVlIG9mICdhJyIgPDwgIiBkZWNsYXJlZCBhcyBleHRlcm46ICIgPDwgYSA8PCAiXG4iOwoKYSA9IDcuNTsKCmNvdXQgPDwgIk1vZGlmaWVkIHZhbHVlIG9mICdhJyIgPDwgIiBkZWNsYXJlZCBhcyBleHRlcm46IiA8PCBhO30KCmludCBtYWluKCl7Cgpjb3V0IDw8ICJFeHRlcm5hbCBTdG9yYWdlIGNsYXNzXG4iOwoKZXh0ZXJuYWxTdG9yYWdlQ2xhc3MoKTsKCnJldHVybiAwO30=
Output:
External Storage class
Value of 'a' declared as extern: 0
Modified value of 'a' declared as extern:7.5
Explanation:
The above code snippet depicts the use of an external storage class.
- In this program, we first declare a float variable 'a' outside of the external storage class.
- Then inside the class, we use the extern keyword to declare 'a' as external. Next, we print its default value 0 using the cout statement.
- Later on, we alter the value of ‘a’ to 7.5 and print it using the cout statement. This depicts how we can make use of external storage classes.
Mutable Storage Class In C++
The mutable storage class is used only for those class objects that have mutable specifiers.
- Data members of a constant object can be modified using the keyword mutable.
- A constant member function can be overridden by a member of a class object using mutable specifiers.
- At times, we might need to change some data members without updating other members of the class, which can be done using the const function.
- In this case, the mutable keyword makes this task much easier to complete, as it allows only a particular data member of the const object to be altered.
- The lifetime of a mutable variable is in the class in which it is declared. It helps a member of a class object to override a const member function.
- The visibility of mutable variables is similar to that of a local variable and has ease of access as it can be accessed anywhere in the entire program. The initial value of mutable storage is a garbage value.
Syntax:
mutable datatype variable_name [= value];
Here,
- mutable is the keyword for the storage default class.
- datatype refers to the type of data in a single variable.
- variable_name denotes the name of the respective variable
- value refers to the initial garbage value of the variable
C++ Program Example:
CODE SNIPPET IS HERE
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmNsYXNzIE11dGFibGUgewoKcHVibGljOgoKaW50IGE7CgptdXRhYmxlIGludCBiOwoKTXV0YWJsZSgpewoKYSA9IDU7CgpiID0gMTA7fQoKfTsKCmludCBtYWluKCl7Cgpjb25zdCBNdXRhYmxlIG0xOwoKbTEuYiA9IDE1OwoKY291dDw8ICJNdXRhYmxlIFN0b3JhZ2UgQ2xhc3MgXG4iOwoKY291dCA8PCJiPSI8PCBtMS5iOwoKcmV0dXJuIDA7fQ==
Output:
Mutable Storage Class
b= 15
Explanation:
The above code snippet depicts the use of a mutable storage class.
- We begin by defining a class Mutable after including the iostream file and namespace std.
- We then define two public variables- the first is int a and the second variable b, which is mutable (which can be modified later on).
- Next, we intialise a and b with the values of 5 and 10, respectively.
- Now, we create an object of the class mutable and try to change the value of b.
- We will notice that only the value of b can be changed as it is of the type mutable storage class.
- We use the cout statement to print the results on the output window.
Conclusion
In this article, we discussed storage classes in C++ and their different types.
- We discussed the scope of variables, lifetime, and visibility of other storage classes.
- It is understood by now that there are five storage classes, namely automatic, register, static, extern, and mutable.
- We have covered all the topics related to storage classes in C++ with syntax, as well as source code examples and uses of it.
Also read- Typedef In C++ | Syntax, Application & How To Use It (With Examples)
Frequently Asked Questions
Q. What is the storage class of functions?
Storage classes in C++ are used for variables or functions in a program to know about their scope, lifetime, visibility, and initial values. These functionalities help us to find the existence of a particular variable/function during the execution of a program.
The general syntax for defining storage class for a variable is as follows:
storage_class variable_data_type variable_name;
Here,
- storage_class refers to the specific type of storage class we are using.
- variable_data_type refers to the type of data
- variable_name refers to the name you give to the variable.
Q. What are the types of storage classes in C++?
Storage classes tell us about the scope of variables as well as their lifespan and visibility. In the C++ programming language, there are five storage classes. These are:
-
Automatic Storage Class
-
Register Storage Class
-
Static Storage Class
-
The extern Storage Class
-
The mutable Storage Class
Q. What is the static storage class?
Static storage class is used to declare static variables, which retain their value even outside the function in which it is declared. The memory allocation for such variables remains until the end of the program. Global static variables have their scope as the entire program.
Syntax:
static datatype variable_name [= value];
Q. What are static variables and static functions in C++?
Static variables are variables whose scope is the same as that of a local variable. Although the memory is allocated for the variable during the whole program until the program ends and memory deallocates.
Static data members are accessed by special functions in C++, which are known as static functions. Any function can be called a static function if we add the keyword static before the function name.
Q. What are member functions in C++?
Memory functions are functions in C++ that are defined in the class itself. These functions work on objects of the class and can have quick access to all the members of that class. Member functions can be written anywhere inside or outside of their class definition.
Q. What is an auto-storage class in C++?
Automatic Storage Class is the default storage class for all local variables, and it is declared as well as accessed only within a particular function/method. In case there's no keyword specified to a variable, it automatically gets assigned with the keyword auto
Syntax:
auto datatype variable_name [= value];
Q. What is the function of the storage system in computers?
The function of a storage system in computers is to store important info/data, modify it, and transfer it from one system to the other. There are various computer storage devices that allow users to save and manipulate data and applications securely on their computers. We all are familiar with some basic examples of storage systems that include hard disks, disk drives, tape systems, and other media types.
Test Your Skills: Quiz Time
This compiles our discussion on storage classes in C++. You might also be interested in reading the following:
- Operators In C++ | Types & Precedence Explained (With Examples)
- Comment In C++ | Types, Usage, C-Style Comments & More (+Examples)
- Strings In C++ | Functions, How To Convert & More (With Examples)
- 51 C++ Interview Questions For Freshers & Experienced (With Answers)
- Pointer To Object In C++ | Simplified Explanation & Examples!
An economics graduate with a passion for storytelling, I thrive on crafting content that blends creativity with technical insight. At Unstop, I create in-depth, SEO-driven content that simplifies complex tech topics and covers a wide array of subjects, all designed to inform, engage, and inspire our readers. My goal is to empower others to truly #BeUnstoppable through content that resonates. When I’m not writing, you’ll find me immersed in art, food, or lost in a good book—constantly drawing inspiration from the world around me.
Login to continue reading
And access exclusive content, personalized recommendations, and career-boosting opportunities.
Subscribe
to our newsletter
Comments
Add comment