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++

std::vector::insert — insert elements into a vector

Insert a value, repeated copies, an initializer list, or an iterator range before a chosen position. Use the returned iterator and know which existing handles become invalid.

Advanced · ISO C++23; implementation support may vary
C++

std::vector::pop_back — Remove the last element

`pop_back()` removes the last element of a non-empty vector without returning its value. For a vector that stores a heap, `std::pop_heap` rearranges the elements; `pop_back()` reduces the size.

Advanced · ISO C++23; implementation support may vary
C++

std::vector::push_back — appending one element

Append one element by copying or from an rvalue. Learn when growth invalidates pointers and why the old `end()` is invalid even when no reallocation occurs.

Advanced · ISO C++23; implementation support may vary
C++

std::vector::swap — exchanging two vectors

Exchange two vectors’ contents and capacities in constant time. Check allocator compatibility and learn which iterators remain usable after the swap.

Advanced · ISO C++23; implementation support may vary
C++

Array `new[]` and `delete[]` vs. single-object forms

Use `delete` for an object created with `new T` and `delete[]` for an array created with `new T[n]`. These expressions manage object lifetimes; the corresponding `operator new` and `operator delete` functions, with or without `[]`, manage storage.

Intermediate · ISO C++23; implementation support may vary
C++

Unary minus in C++

Unary minus negates one operand. In `return -1;`, it produces an `int` value that this function uses to mean “not found”; it is not subtraction.

Advanced · ISO C++23; implementation support may vary
C++

Unary negation (`-`) in C++

Unary minus computes the negative of one operand, whereas binary subtraction computes a difference. The promoted type determines what happens at the limits of its range.

Advanced · ISO C++23; implementation support may vary
C++

Unsigned integer literal suffix `u`

The suffix `u` or `U` selects an unsigned integer type, not a fixed width. `0u` and `1u` are `unsigned int`; a larger value can require a wider type.

Advanced · ISO C++23; implementation support may vary
C++

The `ULL` integer literal suffix

`ULL` gives an integer literal the type `unsigned long long` when its value fits, which can change overload selection or how a bit shift is evaluated.

Advanced · ISO C++23; implementation support may vary
C++

UTF-8 code units, code points and grapheme clusters in C++

UTF-8 text has different lengths depending on what you count: code units, code points or grapheme clusters. The example counts and truncates well-formed UTF-8 without splitting a code point.

Advanced · ISO C++23; implementation support may vary
C++

Value-initialization and empty braces `{}` in C++23

Empty braces do not always mean value-initialization. The type determines whether they initialize a scalar, call a constructor, or apply the rules for aggregates.

Advanced · ISO C++23; implementation support may vary
C++

C++ structured bindings with `auto [a, b, c]`

A structured binding names the components of one object. Choosing `auto`, `auto&`, or `const auto&` changes how that object is stored or referred to.

Intermediate · ISO C++23; implementation support may vary
C++

Forwarding reference T&&

A forwarding reference T&& lets a template accept lvalues and rvalues while retaining the information needed to forward the argument onward. It requires the appropriate deduction context; && alone is not enough.

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

Lvalue reference: T&

A T& reference aliases an object or a function without making a copy. It cannot be reseated after initialization. For object types, const T& restricts modification through the reference and can also bind to a suitable temporary object.

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

Pointer-to-member declarators

A pointer to member identifies a non-static data member or member function without binding to a particular object. Declare it using C::*, then apply it to an object with .* or through an object pointer with ->*.

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

T* pointer declarator

The `T*` declarator forms the type “pointer to T”. In `int* p = &value;`, `p` holds a pointer to `value`, not a copy of that integer. The position of `const` determines whether the restriction applies to the pointed-to object or to the pointer itself.

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