Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C++

Knowledge base — C++

Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.

Entries: 674

C++

Operator ->*: member access through an object pointer

The built-in ->* operator combines an object pointer with a pointer to a class member. It lets you read or modify a data member, or call a member function selected by that member pointer.

Intermediate · C++23; repository compiler flag, production runtime not attested
C++

Operator |: composing range adaptors

Operator | either applies an adaptor closure to a range or composes two closures into a pipeline. Distinguish R | C, which invokes the adaptor, from C | D, which creates an operation for later use.

Intermediate · C++23; repository compiler flag, production runtime not attested
C++

reinterpret_cast — low-level type casting

reinterpret_cast performs selected low-level conversions, primarily involving pointers and references. The cast itself does not authorize access through an incompatible type: aliasing, alignment, and object-lifetime rules still apply.

Advanced · C++23; repository compiler flag, production runtime not attested
C++

Remainder operator %

The built-in % operator computes the remainder of integer division. It is not a percentage operator or a guarantee of nonnegative modulo: a nonzero remainder has the sign of the dividend after type conversions. A zero divisor or an unrepresentable quotient causes undefined behavior.

Basic · C++23; repository compiler flag, production runtime not attested
C++

Remainder assignment operator (%=)

The %= operator calculates a remainder and stores it in its left operand. The left side is evaluated only once. The built-in operator requires a modifiable integral object; a zero divisor causes undefined behavior.

Basic · C++23; repository compiler flag, production runtime not attested
C++

Right-shift operator >>

The built-in >> operator shifts an integer's bits to the right. In C++23, its result corresponds to division by a power of two, rounded toward negative infinity. The number of positions shifted must be within the permitted range.

Basic · C++23; repository compiler flag, production runtime not attested
C++

Right-shift assignment operator (>>=)

The >>= operator shifts the left operand's bits to the right and stores the result in the same object. The left operand is evaluated only once. Validity depends on the shift count and the type after integral promotion.

Basic · C++23; repository compiler flag, production runtime not attested
C++

Scope resolution operator (::)

The :: operator qualifies a name by specifying the namespace, class, or enumeration in which it is looked up. A leading :: denotes the global namespace. It helps distinguish hidden names and define member functions outside the class definition.

Basic · C++23; repository compiler flag, production runtime not attested
C++

sizeof — size of a type or object in bytes

The sizeof operator returns a type's size in bytes as a constant of type std::size_t. Its expression operand is not evaluated, and an array retains its full size rather than being converted to a pointer.

Basic · C++23; repository compiler flag, production runtime not attested
C++

sizeof... — number of elements in a pack

The sizeof... operator computes the number of elements in a parameter pack, not their size in bytes. Its result is an integral constant of type std::size_t; an empty pack yields 0.

Intermediate · C++23; repository compiler flag, production runtime not attested
C++

Operator <=> — three-way comparison

The <=> operator, called spaceship, describes an ordering relationship between values. Standard result categories distinguish less, equivalent, greater, and sometimes unordered. In a class, a defaulted definition provides lexicographical comparison of subobjects.

Intermediate · C++23; repository compiler flag; example execution verified in isolation, production runtime not attested
C++

static_cast — explicit type conversion

static_cast<T>(expression) explicitly converts an expression to T under the language's conversion rules. The compiler checks whether the conversion is permitted, but does not guarantee value preservation or the validity of a class-hierarchy downcast.

Intermediate · C++23; repository compiler flag, production runtime not attested
C++

Stream insertion operator <<

The << operator writes values to an output stream. Learn the distinction between member overloads and non-member functions, and how to support a custom type while preserving chained insertion.

Basic · C++23; repository compiler flag, production runtime not attested
C++

Subtraction operator and unary minus

The symbol `-` means subtraction in `a - b` and arithmetic negation in `-x`. It can also move a pointer or calculate the distance between pointers. Correct results depend on type conversions, numeric ranges, and array boundaries.

Basic · C++23; repository compiler flag, production runtime not attested
C++

Subtraction assignment operator (-=)

The -= operator subtracts the right operand from the left operand's value and stores the result in the left object. For the built-in operator, the left operand is evaluated only once; type conversions and pointer arithmetic restrictions still apply.

Basic · C++23; repository compiler flag, production runtime not attested
C++

typeid — type identification

The typeid operator exposes type information. For a polymorphic glvalue it identifies the dynamic type; otherwise it uses the static type.

Intermediate · C++23; repository compiler flag, production runtime not attested
C++

Unary minus

Unary minus, written as -expression, computes the negated value. Learn how integral promotions affect the result, how unsigned negation works, and when signed overflow is a risk.

Basic · C++23; repository compiler flag, production runtime not attested
C++

Unary plus operator (+)

Unary + preserves its operand's value but can change its type through integral promotion. For an eligible noncapturing lambda, it can also force conversion to a function pointer.

Intermediate · C++23; repository compiler flag, production runtime not attested
C++

#include — header inclusion

The #include directive makes a header or source file's contents available during preprocessing. The <header> and "file" forms use different searches; the implementation defines the specific search rules.

Basic · C++23; repository compiler flag, production runtime not attested
C++

Aggregate initialization

Aggregate initialization initializes the elements of an aggregate, usually with a brace-enclosed list. Learn element ordering, omitted-member values, and the restrictions on designated initializers in C++23.

Intermediate · C++23; repository compiler flag, production runtime not attested
C++

Type alias declaration with using

The declaration using AliasName = Type; gives a type another name without creating a distinct type. Learn its equivalence to typedef and how const applies to pointer aliases.

Basic · C++23; repository compiler flag, production runtime not attested
C++

Array declarator: T name[N]

T name[N] declares a built-in array of N elements of type T. Its bound must be a positive compile-time constant; the elements occupy contiguous storage.

Basic · C++23; repository compiler flag, production runtime not attested
C++

Class template argument deduction and deduction guides

CTAD lets you omit class template arguments when initializing an object. The compiler selects a specialization using candidates derived from constructors and deduction guides. A guide selects the type but does not replace a constructor.

Intermediate · C++23; repository compiler flag, production runtime not attested
C++

Const-qualified member function

A const qualifier after a member function's parameter list restricts modification of the object through this. It permits calls through const objects, references, and pointers, but does not imply complete freedom from side effects.

Intermediate · C++23; repository compiler flag, production runtime not attested