Punctuation
From cppreference.com
These are the punctuation symbols in C++. The meaning of each symbol is detailed in the linked pages.
[edit] Preprocessing operators
Preprocessing operators are recognized by preprocessors.
[edit] # (including %:)
- Introduce a preprocessing directive.
- The preprocessing operator for stringification.
[edit] ##(including %:%:)
[edit] Single-character operators and punctuators
[edit] { and } (including <% and %>)
- In a class definition, delimit the member specification.
- In an enumeration definition, delimit the enumerator list.
- Delimit a compound statement. The compound statement may be part of
(since C++11) |
- Part of the aggregate initialization(until C++11)list-initialization(since C++11) syntax of an initializer.
- In a namespace definition, delimit the namespace body.
- In a language linkage specification, delimit the declarations.
|
(since C++20) |
[edit] [ and ] (including <: and :>)
- Subscript operator; part of operator[] in operator overloading.
- Part of array declarator in a declaration or a type-id (e.g. in a new expression).
- Part of new[] operator in operator overloading (allocation function).
- Part of delete[] operator in delete expression and operator overloading (deallocation function).
|
(since C++11) |
|
(since C++17) |
|
(since C++26) |
[edit] ( and )
- In an expression, indicate grouping.
- Function call operator; part of operator() in operator overloading.
- In a function-style type cast, delimit the expression/initializers.
- In a
static_cast
,const_cast
,reinterpret_cast
, ordynamic_cast
, delimit the expression. - Delimit the operand of the following operators:
(since C++11) |
- In a placement new expression, delimit the placement arguments.
- In a new expression, optionally delimit the type-id.
- In a new expression, delimit the initializers.
- In a C-style cast, delimit the type-id.
- In a declaration or a type-id, indicate grouping.
- Delimit the parameter list in
- a function declarator (in a declaration or a type-id)
(since C++11) | |
(since C++17) | |
(since C++20) |
- Part of the direct-initialization syntax of an initializer.
- In an asm declaration, delimit the string literal.
- In a member initializer list, delimit the initializers to a base or member.
- Delimit the controlling clause of a selection statement or iteration statement, including:
(since C++11) |
- In a handler, delimit the parameter declaration.
- In a function-like macro definition, delimit the macro parameters.
- In a function-like macro invocation, delimit the macro arguments or prevent commas from being interpreted as argument separators.
- Part of a
defined
,__has_include
(since C++17),__has_cpp_attribute
(since C++20) preprocessing operator.
|
(since C++11) | ||
|
(since C++14) | ||
|
(since C++17) | ||
|
(since C++20) |
[edit] ;
- Indicate the end of
|
(since C++20) |
- Separate the condition and statement of a for statement.
[edit] :
- Part of conditional operator.
- Part of label declaration.
- In the base-clause of a class definition, introduce the base class.
- Part of access specifier in member specification.
- In a bit-field member declaration, introduce the width.
- In a constructor definition, introduce the member initializer list.
|
(since C++11) |
|
(since C++17) |
|
(since C++20) |
[edit] ?
- Part of conditional operator.
[edit] .
|
(since C++20) |
[edit] ~ (including compl)
- Unary complement operator (a.k.a. bitwise not operator); part of operator~ in operator overloading.
- Part of an identifier expression to name a destructor or pseudo-destructor.
[edit] ! (including not)
- Logical not operator; part of operator! in operator overloading.
|
(since C++23) |
[edit] +
- Unary plus operator; part of operator+ in operator overloading.
- Binary plus operator; part of operator+ in operator overloading.
[edit] -
- Unary minus operator; part of operator- in operator overloading.
- Binary minus operator; part of operator- in operator overloading.
[edit] *
- Indirection operator; part of operator* in operator overloading.
- Multiplication operator; part of operator* in