Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP C C++ C# AWS W3.CSS HOW TO BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING INTRO TO HTML & CSS BASH RUST TOOLS

C++ Tutorial

C++ HOME C++ Intro C++ Get Started C++ Syntax C++ Output C++ Comments C++ Variables C++ User Input C++ Data Types C++ Operators C++ Type Conversion C++ Strings C++ Math C++ Booleans C++ If...Else C++ Switch C++ While Loop C++ For Loop C++ Break/Continue C++ Arrays C++ Structures C++ Enums C++ References C++ Pointers C++ Memory Mgmt

C++ Functions

C++ Functions C++ Function Parameters C++ Function Overloading C++ Scope C++ Recursion C++ Lambda

C++ Classes

C++ OOP C++ Classes/Objects C++ Class Methods C++ Constructors C++ Destructors C++ The this Pointer C++ Access Specifiers C++ Encapsulation C++ Friend Functions C++ Inheritance C++ Polymorphism C++ Operator Overload C++ Templates

C++ Files

C++ Files

C++ Date

C++ Date

C++ Errors

C++ Errors C++ Debugging C++ Exceptions C++ Input Validation

C++ Problem Solving

C++ Problem Solving C++ Build the Logic C++ Test Cases

C++ Projects

C++ Projects

C++ Data Structures

C++ Data Structures & STL C++ Vectors C++ List C++ Stacks C++ Queues C++ Deque C++ Sets C++ Maps C++ Unordered Map C++ Unordered Set C++ Iterators C++ Algorithms

C++ Namespaces

C++ Namespaces

C++ Cert

C++ Certificate

C++ How To

C++ How Tos

C++ Examples

C++ Examples C++ Real-Life Examples C++ Compiler C++ Exercises C++ Quiz C++ Code Challenges C++ Practice Problems C++ Syllabus C++ Study Plan C++ Interview Q&A

C++ Reference

C++ Reference C++ Keywords C++ <algorithm> C++ <cctype> C++ <cmath> C++ <cstdlib> C++ <cstring> C++ <ctime> C++ <deque> C++ <fstream> C++ <iomanip> C++ <iostream> C++ <list> C++ <map> C++ <memory> C++ <queue> C++ <random> C++ <set> C++ <sstream> C++ <stack> C++ <stdexcept> C++ <string> C++ <unordered_map> C++ <unordered_set> C++ <vector>


C++ Keywords


Share

C++ Keywords

A list of all C++ keywords can be found in the table below.

Keyword Description
alignas Specifies the alignment (the memory address boundary) of a variable or type
alignof Returns the alignment of a type, in bytes
and An alternative way to write the logical && operator
and_eq An alternative way to write the &= assignment operator
asm Lets you write assembly code (low-level processor instructions) inside C++ code
auto Automatically detects the type of a variable based on the value you assign to it
bitand An alternative way to write the & bitwise operator
bitor An alternative way to write the | bitwise operator
bool A data type that can only store true or false values
break Breaks out of a loop or a switch block
case Marks a block of code in switch statements
catch Catches exceptions generated by try statements
char A data type that can store a single character
char16_t A data type that can store a 16-bit character, used for UTF-16 text
char32_t A data type that can store a 32-bit character, used for UTF-32 text
class Defines a class
compl An alternative way to write the ~ bitwise operator
const Defines a variable or parameter as a constant (unchangeable) or specifies that a class method does not modify attributes of the class
const_cast Converts a value by adding or removing const
constexpr Specifies that the value of a variable or function can be calculated when the program is compiled
continue Continues to the next iteration of a loop
decltype Gets the type of an expression, so you can declare a variable with the same type
default Specifies the default block of code in a switch statement
delete Frees dynamic memory
do Used together with while to create a do/while loop
double A data type that is usually 64 bits long which can store fractional numbers
dynamic_cast Converts a pointer or reference from a parent class to a child class, and checks that it is safe while the program runs
else Used in conditional statements
enum Declares an enumerated type
explicit Prevents a constructor from being used for automatic (implicit) type conversions
export Reserved for future use (C++20 uses it for modules)
extern Declares a variable or function that is defined in another file
false A boolean value equivalent to 0
final Prevents a class from being inherited, or a virtual method from being overridden
float A data type that is usually 32 bits long which can store fractional numbers
for Creates a for loop
friend Specifies classes and functions which have access to private and protected members
goto Jumps to a line of code specified by a label
if Makes a conditional statement
inline Suggests to the compiler that the code of a function should be inserted where the function is called
int A data type that is usually 32 bits long which can store whole numbers
long Ensures that an integer is at least 32 bits long (use long long to ensure 64 bits)
mutable Allows an attribute to be changed, even in a const object or method
namespace Declares a namespace
new Reserves dynamic memory
noexcept Specifies that a function does not throw exceptions
not An alternative way to write the logical ! operator
not_eq An alternative way to write the != comparison operator
nullptr A pointer value that does not point to anything
operator Defines how an operator, like +, works for a class (operator overloading)
or An alternative way to write the logical || operator
or_eq An alternative way to write the |= assignment operator
override Specifies that a method overrides a virtual method from the parent class
private An access modifier which makes a member only accessible within the declared class
protected An access modifier which makes a member only accessible within the declared class and its children
public An access modifier which makes a member accessible from anywhere
register Not used since C++17, but the word is still reserved. It was used to suggest that a variable should be stored in a CPU register
reinterpret_cast Converts a pointer to an unrelated pointer type (a low-level conversion)
return Used to return a value from a function
short Reduces the size of an integer to 16 bits
signed Specifies that an int or char can represent positive and negative values (this is the default so the keyword is not usually necessary)
sizeof An operator that returns the amount of memory occupied by a variable or data type
static Specifies that an attribute or method belongs to the class itself instead of instances of the class
Specifies that a variable in a function keeps its value after the function ends
static_assert Checks a condition when the program is compiled, and stops with an error message if it is false
static_cast Converts a value from one type to another, like a double to an int
struct Defines a structure
switch Selects one of many code blocks to be executed
template Declares a template class or template function
this A variable that is available inside class methods and constructors which contains a pointer to a class instance
thread_local Specifies that each thread has its own copy of a variable
throw Creates a custom error which can be caught by a try...catch statement
true A boolean value equivalent to 1
try Creates a try...catch statement
typedef Defines a custom data type
typeid Returns information about the type of a variable or expression
typename Declares a type parameter in a template, or tells the compiler that a name is a type
union Defines a union, a type where all members share the same memory
unsigned Specifies that an int or char should only represent positive values which allows for storing numbers up to twice as large
using Allows variables and functions from a namespace to be used without the namespace's prefix
virtual Specifies that a class method is virtual
void Indicates a function that does not return a value or specifies a pointer to a data with an unspecified type
volatile Tells the compiler that a variable can change at any time, for example by hardware, so it must always read the value from memory
wchar_t A data type that can store a wide character, which can be larger than a char
while Creates a while loop
xor An alternative way to write the ^ bitwise operator
xor_eq An alternative way to write the ^= assignment operator

Note: override and final are not reserved words, so you can still use them as names. They only have a special meaning in a class.

Note: The table lists the keywords in C++11. Newer versions of C++ added a few more, like concept, requires and co_await (C++20).



Free account

Track your progress

XP earned 0 Day streak 0 Spaces 0 League —

New

Learn in Adventure Mode W3Schools Adventure App

Coding fundamentals as bite-sized lessons and challenges.

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookies and privacy policy.

Copyright 1999-2026 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.