Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Knowledge base

Knowledge base

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

Entries: 5788

C++

C language linkage: `extern "C"`

`extern "C"` specifies language linkage for interoperability between C and C++. It does not switch the compiler to C or guarantee binary compatibility on its own.

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

Copy elision and NRVO in C++

Returning by value does not necessarily copy an object. Distinguish optional NRVO for a named local from guaranteed direct construction from a same-type prvalue.

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

Formatting numbers with cout.setf and setprecision(2)

Set `std::cout` to fixed-point notation with two digits after the decimal separator. Learn why the `floatfield` mask matters and how to restore the previous format.

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

C-style ellipsis fallback

A standalone ellipsis in `test(...)` provides a fallback overload when a typed probe cannot match. It is not a template parameter pack or pack expansion.

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

Data-oriented design: AoS, SoA, and cache locality

Choose a layout around how your program uses its data: compare whole records with separate columns, then measure the effect on a representative workload.

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

`= default` — explicitly defaulted functions in C++

`= default` asks the compiler to supply the standard definition of an eligible function. Ownership, PImpl, and virtual destructors show where this matters.

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

Using `= default` on a virtual destructor

Declare a public virtual base-class destructor so a derived object can be deleted through a base pointer without writing a destructor body for the base class.

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

Defaulted special member functions (`= default`) in C++

In C++23, `= default` asks the compiler for the standard definition of a special member function. Definition placement matters in Pimpl; C++23 implementation support may vary.

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

`= delete`: deleted functions and exclusive ownership

`= delete` forbids use of a function at compile time. A coroutine frame owner can use it to forbid copying while still transferring ownership by moving and releasing the frame in its destructor.

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

Deleted function (`= delete`)

Reject a specific overload or prevent copying at compile time while keeping a class movable and handling destruction of its hidden implementation correctly.

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

Deleted functions (`= delete`) in C++

`= delete` makes a specific function unusable at compile time. Use it to reject an unwanted overload or to prevent an owning pool from being copied or moved.

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

C++ exception safety: basic, strong, and no-throw guarantees

The basic guarantee permits partial changes that leave valid state. The strong guarantee leaves no observable change on exception. The no-throw guarantee prevents exceptions from reaching the caller.

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

Feature flag and compile-time configuration

A compile-time flag selects a program variant when you build it. A runtime flag changes the behavior of an already-built program.

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

The `f` suffix on floating-point literals

Append `f` or `F` to make a floating-point literal a `float` rather than the default `double`. This affects type deduction and overload resolution.

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

The forwarding reference `F&&`

With `F` deduced, `F&&` can bind to either an lvalue or an rvalue. A direct call `f()` treats the callable as an lvalue; `std::forward<F>(f)` passes it on as an lvalue or rvalue according to the argument.

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

Heterogeneous lookup with a transparent comparator

Search an ordered associative container with a different type from its key, without constructing a temporary key. Learn why `std::less<>` enables the lookup overloads and why mixed comparisons must agree with the key order.

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

Implicit move from a return parameter

In C++23, `return a;` can move from a by-value parameter. This is not NRVO: the parameter is a separate object from the result.

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

Inline variable: one object across translation units

Define an inline variable with external linkage in a shared header to give multiple translation units the same object. Compare it with an ordinary namespace-scope `const` that gives each translation unit its own object.

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