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

private — private member access and inheritance

The private keyword restricts access to class members to the class's members and friends. In a base clause, it specifies private inheritance. This is a program correctness check, not a memory-security boundary.

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

protected — protected access

The protected keyword controls member access or inheritance access. It makes members available to derived classes without exposing them to ordinary outside code, but adds restrictions on the object expression used to access non-static members.

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

public — public access and public inheritance

The public keyword specifies public access to class members or public inheritance. A public: section exposes a class interface, while : public Base preserves the public and protected access levels of base-class members.

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

register — reserved keyword after removal of the specifier

In C++23, register remains a reserved keyword but is not a permitted storage-class specifier. Its former use in declarations was removed in C++17; migration usually only requires removing register.

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

requires — constraints and requirement checking

The requires keyword introduces either a clause constraining a declaration or an expression checking requirements on types and operations. Distinguishing these uses helps you write templates whose availability depends on the capabilities of the supplied type.

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

return — ending a function and returning a result

The return statement ends the current function call and transfers control to its caller. It can also initialize a returned value or reference. It is not equivalent to break: inside a loop, it exits the entire function.

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

signed — signed integer type specifier

The signed keyword specifies a signed integer type. Used alone, signed means int; with short, int, long, and long long it is redundant. However, signed char is a distinct type from both char and unsigned char.

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

static — persistent state, internal linkage, and class members

The meaning of static depends on the declaration's location: a local variable retains state between calls, a namespace-scope name gets internal linkage, and a class member does not require a separate copy in every object. Storage duration, scope, and linkage are different concepts.

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

static_assert — a compile-time assertion

static_assert checks a constant condition during compilation. A false condition outside the context of a template definition makes the program ill-formed and requires a diagnostic. An optional string literal describes the violated assumption.

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

struct — defining a class type

The struct keyword declares a class type that can combine data and member functions. Unlike class, its default member access and default inheritance are public. Using struct alone does not guarantee that the type is an aggregate.

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

switch — selection by value

The switch statement transfers control to a case label matching the condition's value, or to an optional default label. Labels do not end a branch: break exits switch, while [[fallthrough]]; marks intentional continuation.

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

template — declaring templates and disambiguating names

The template keyword introduces templates: families of related declarations parameterized by types, values, or other templates. It also appears in explicit specialization, explicit instantiation, and syntax that identifies a dependent member name as a template.

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

this — pointer to the current object

The keyword this points to the object handled by an implicit object member function. It enables explicit member access, distinguishes a data member from a parameter with the same name, and lets a function return the current object by reference.

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

thread_local — a separate variable for each thread

The thread_local keyword gives a variable thread storage duration: each thread has its own instance, retained between function calls. It does not create one shared variable protected against concurrent access.

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

throw — throwing and rethrowing exceptions

The throw keyword throws an exception from an expression or rethrows the currently handled exception. Learn the distinction between throw expression; and throw;, how stack unwinding works, and which situations lead to std::terminate.

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

true — Boolean truth literal

`true` is a C++ keyword and a literal of type `bool` representing truth. It is not the integer literal `1`, although promotion to `int` produces `1`. One common use is initializing Boolean variables.

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

try — exception-handling block

The try keyword introduces a block associated with one or more catch handlers. An exception thrown in that block or in a function it calls can transfer control to a matching handler. The function-try-block form also provides handlers for a function body.

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

typedef — type alias

The typedef keyword gives a type an additional name without creating a distinct type. Declarator syntax also lets it name pointer, array, and function types.

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

typename — type parameters and type-name disambiguation

The typename keyword declares a template type parameter or indicates that a qualified name denotes a type. These roles are distinct: class can replace typename when declaring a type parameter, but not when disambiguating a name such as T::value_type.

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

union — shared storage for alternative members

The union keyword defines a class type whose non-static data members share storage. At most one member can be active at a time; correct use requires tracking member lifetimes.

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

unsigned — unsigned integer types

The unsigned keyword specifies an unsigned integer type; unsigned alone means unsigned int. Learn its valid combinations, modulo arithmetic, and the conversion and comparison pitfalls that arise when mixing signed and unsigned types.

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

using — type aliases and making names available

The using keyword has several distinct uses: it creates type aliases, makes selected declarations available, affects namespace name lookup, and exposes enumerators. Distinguish these forms: not every using declaration creates an alias.

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

virtual — virtual functions and virtual inheritance

The virtual keyword has two separate uses: it enables selection of an overriding member function according to an object's dynamic type, and it marks a virtual base class shared within an inheritance hierarchy. Neither mechanism requires the other.

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

volatile — type qualifier

`volatile` qualifies a type and gives accesses through such expressions observable significance. It can support hardware access under implementation-specific rules, but it provides neither atomicity nor inter-thread synchronization.

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