
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Hello World
- C++ Omitting Namespace
- C++ Tokens
- C++ Constants/Literals
- C++ Keywords
- C++ Identifiers
- C++ Data Types
- C++ Numeric Data Types
- C++ Character Data Type
- C++ Boolean Data Type
- C++ Variable Types
- C++ Variable Scope
- C++ Multiple Variables
- C++ Basic Input/Output
- C++ Modifier Types
- C++ Storage Classes
- C++ Numbers
- C++ Enumeration
- C++ Enum Class
- C++ References
- C++ Date & Time
- C++ Operators
- C++ Arithmetic Operators
- C++ Relational Operators
- C++ Logical Operators
- C++ Bitwise Operators
- C++ Assignment Operators
- C++ sizeof Operator
- C++ Conditional Operator
- C++ Comma Operator
- C++ Member Operators
- C++ Casting Operators
- C++ Pointer Operators
- C++ Operators Precedence
- C++ Unary Operators
- C++ Control Statements
- C++ Decision Making
- C++ if Statement
- C++ if else Statement
- C++ Nested if Statements
- C++ switch Statement
- C++ Nested switch Statements
- C++ Loop Types
- C++ while Loop
- C++ for Loop
- C++ do while Loop
- C++ Foreach Loop
- C++ Nested Loops
- C++ break Statement
- C++ continue Statement
- C++ goto Statement
- C++ Strings
- C++ Strings
- C++ Loop Through a String
- C++ String Length
- C++ String Concatenation
- C++ String Comparison
- C++ Functions
- C++ Functions
- C++ Multiple Function Parameters
- C++ Recursive Function
- C++ Return Values
- C++ Function Overloading
- C++ Function Overriding
- C++ Default Arguments
- C++ Arrays
- C++ Arrays
- C++ Multidimensional Arrays
- C++ Pointer to an Array
- C++ Passing Arrays to Functions
- C++ Return Array from Functions
- C++ Structure & Union
- C++ Structures
- C++ Unions
- C++ Pointers
- C++ Pointers
- C++ Dereferencing
- C++ Modify Pointers
- C++ Class and Objects
- C++ Object Oriented
- C++ Classes & Objects
- C++ Class Member Functions
- C++ Class Access Modifiers
- C++ Static Class Members
- C++ Static Data Members
- C++ Static Member Function
- C++ Inline Functions
- C++ this Pointer
- C++ Friend Functions
- C++ Pointer to Classes
- C++ Constructors
- C++ Constructor & Destructor
- C++ Default Constructors
- C++ Parameterized Constructors
- C++ Copy Constructor
- C++ Constructor Overloading
- C++ Constructor with Default Arguments
- C++ Delegating Constructors
- C++ Constructor Initialization List
- C++ Dynamic Initialization Using Constructors
- C++ Inheritance
- C++ Inheritance
- C++ Multiple Inheritance
- C++ Multilevel Inheritance
- C++ Object-oriented
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
- C++ Virtual Function
- C++ Pure Virtual Functions & Abstract Classes
- C++ File Handling
- C++ Files and Streams
- C++ Reading From File
- C++ Advanced
- C++ Exception Handling
- C++ Dynamic Memory
- C++ Namespaces
- C++ Templates
- C++ Preprocessor
- C++ Signal Handling
- C++ Multithreading
- C++ Web Programming
- C++ Socket Programming
- C++ Concurrency
- C++ Advanced Concepts
- C++ Lambda Expression
- C++ unordered_multiset
C++ Keywords
In C++, keywords are reserved words that have special meanings to the compiler. They cannot be used for any other purpose or as identifiers, such as variables or function names. It’s a predefined words that are part of the C++ syntax. They help define the structure and behavior of the code.
Basic Data Type keywords
These keywords define basic data types −
- int − integer data type.
- char − character data type.
- float − single-precision floating-point data type.
- double − double-precision floating-point data type.
- void − indicates no value or type; commonly used for functions that do not return a value.
- Bool − boolean data type (true or false).
- wchar_t − Represents wide character type mainly useful for internationalization.
Control Flow Keywords
Control flow keywords are special reserved words in programming that are used for implementing decision-making and repetitive tasks in programming.
- Conditional Statements − if, else, switch, case, default
- Looping Constructs − for, while, do
- Control Statements − break, continue, return, goto
Storage Class Keywords
These keywords specify the storage duration and linkage of variables −
- auto − The compiler automatically deduces the variable's type (in C++11 and later).
- Register − It suggests that the variable should be stored in a CPU register for faster access.
- Static − It indicates that the variable retains its value even after the scope in which it was defined ends.
- extern − It declares a variable that is defined in another translation unit.
- Mutable − It allows a member of a class to be modified even if the object is constant.
Modifiers
These keywords are used in modifying the properties of data types −
- const − It indicates that a variable's value cannot be changed after initialization.
- volatile − It indicates that a variable's value may change unexpectedly, preventing certain compiler optimizations.
- signed − It indicates that a data type can hold both positive and negative values.
- unsigned − It indicates that a data type can only hold non-negative values.
- short − It indicates a shorter version of the integer type.
- long − It indicates a longer version of the integer type.
Function Keywords
These keywords define specific behavior for functions
- inline − Suggests to the compiler to attempt to expand the function inline, reducing the overhead of a function call.
- virtual − Indicates that a function can be overridden in derived classes.
- explicit − Prevents implicit conversions for constructors or conversion operators.
Class and Object Keywords
These keywords are fundamental concepts in object-oriented programming (OOP) that enable developers to define and manipulate user-defined data types.
- Class Definitions − class, struct, union, enum
- Namespace Management − namespace, this
- Memory Management − new, delete
Access Specifiers
Access specifiers are keywords in object-oriented programming that define the accessibility or visibility of class members (attributes and methods) to other parts of a program.
- public
- protected
- private
Exception Handling Keywords
These keywords are used for handling exceptions
- try − It defines a block of code to be tested for exceptions.
- catch − It defines a block of code that handles exceptions thrown by a corresponding try.
- throw − Used to signal the occurrence of an exception.
Operator Keywords
Operator keywords are keywords that allow you to define or change how operators (like +, -, *, etc.) work with custom data types, such as classes.
- sizeof
- typeid
- alignof
- alignas
Namespace Keywords
These keywords manage the scope of identifiers
- namespace − Defines a scope that can contain identifiers to avoid name collisions.
- using − Allows the use of names from a namespace without qualification.
Type Casting Keywords
These keywords are used for explicit type conversions
- static_cast − It performs a compile-time type check and conversion.
- dynamic_cast − Safely converts pointers or references within an inheritance hierarchy (requires RTTI).
- const_cast − It adds or removes const or volatile qualifiers.
- reinterpret_cast − It converts any pointer type to any other pointer type with no safety checks.
Miscellaneous Keywords
Some other keywords provided by the C++ library, that serve various purposes beyond the core functionalities of data types, control flow, or object-oriented programming.
- using, typedef
- Type Traits − decltype, static_assert
- Casting Operators − static_cast, dynamic_cast, const_cast, reinterpret_cast
Keywords Vs. Identifiers
Keywords are predefined and reserved by the programming language, it has specific functions and meanings in the language while identifiers are user-defined names for program elements, They are created to represent variables, functions, and other entities in the code.
Example
Keywords | Identifiers |
int, float, while, public, private, class, return, etc. | myVariable, calculateSum, Person, _tempValue, etc. |