C++ language

From Cppreference

< cpp
Jump to: navigation, search

This is a brief reference of available C++ constructs.


[edit] General topics

[edit] Preprocessor

[edit] Comments

[edit] Keywords

[edit] ASCII chart

[edit] Escape sequences

[edit] Flow control

[edit] Conditional execution statements

Different code paths are executed according to the value of given expression

[edit] Iteration statements

The same code is executed several times

[edit] Jump statements

Continue execution at a different location

[edit] Functions

The same code can be reused at different locations in the program

[edit] Exceptions

Exceptions are a more robust way to signal error condition than function return codes or global error variables

[edit] Namespaces

Namespaces provide a way to prevent name clashes in large projects

[edit] Types

[edit] Specifiers

[edit] Operators

Common operators
assignment increment
arithmetic logical comparison member
a = b

a = rvalue
a += b
a -= b
a *= b
a /= b
a %= b
a &= b
a |= b
a ^= b
a <<= b
a >>= b




a + b
a - b
a * b
a / b
a % b
a & b
a | b
a ^ b
a << b
a >> b


a && b
a || b

a == b

a != b
a < b
a > b
a <= b
a >= b




a, b
(type) a
? :

Special operators

static_cast converts one type to another compatible type
dynamic_cast converts virtual base class to derived class
const_cast converts type to compatible type with different cv qualifiers
reinterpret_cast converts type to incompatible type
new allocates memory
delete deallocates memory
sizeof queries the size of a type
sizeof... queries the size of a parameter pack (C++11 feature)
typeid queries the type information of a type
noexcept checks if an expression can throw an exception (C++11 feature)
alignof queries alignment requirements of a type (C++11 feature)

[edit] Utilities

Memory allocation

[edit] Classes

Classes provide the concept of object-oriented programming in C++

[edit] Special member functions

[edit] Templates

Allows functions and classes to operate on generic types