else — the alternative branch of an if statement
The else keyword introduces an optional branch of an if statement, selected when the condition is false. The spelling else if nests another if; braces make branch association explicit.
CKTIS / C++
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
The else keyword introduces an optional branch of an if statement, selected when the condition is false. The spelling else if nests another if; braces make branch association explicit.
The enum keyword defines a distinct type with named constants. Learn the differences between enum and enum class, value numbering, and underlying-type selection.
The explicit specifier restricts constructors and conversion functions in implicit conversions while preserving deliberate object construction. Learn the distinction between direct- and copy-initialization, the special role of operator bool, and conditional explicit(condition).
The `export` keyword marks a module interface unit, exposes declarations to importers, or re-exports an import. Writing `export module M;` alone does not automatically export all subsequent declarations.
extern lets you declare variables and functions while separating a declaration from a definition. It does not mean that the definition must be in another file. It also appears in language linkage specifications such as extern "C" and in explicit instantiation declarations for templates.
The keyword false is a literal of type bool representing logical falsity. It can initialize flags and control conditions. Promotion to int produces 0, but false itself is not an integer literal.
The final specifier prevents further overriding of a virtual function or use of a class as a base class. These restrictions are checked at compile time. It does not make an object immutable and does not replace override.
The for keyword creates either a classic loop with initialization, a condition, and an update, or a range-based loop over elements. Choose the form according to whether you need explicit index control or access to successive elements.
A friend declaration lets a nominated function or class access private and protected members without making it a member of the granting class.
The goto statement unconditionally transfers control to a named label in the same function. It can exit multiple nested loops, but remains subject to the rules for initializing and destroying local objects.
The if statement selects a branch using a condition contextually converted to bool. Learn optional else branches, else if chains, initialization before the condition, and the distinction between ordinary if, if constexpr, and if consteval.
`import` makes a named module's exported interface, a partition of the current module, or a header unit available. It does not textually paste contents like `#include`; importing a named module does not make macros available.
inline allows function and variable definitions in headers while respecting the one-definition rule. It does not force call-site substitution or guarantee a faster program.
`module` specifies that a translation unit belongs to a named module or starts a module fragment. Distinguish `export module M;`, `module M;`, and `import M;`: they declare an interface, an implementation, and use of a module, respectively.
The mutable keyword allows a selected data member to change even in a const object. In a lambda it has a different role: it removes the call operator's default const qualification, allowing modification of modifiable copies of captured values.
The namespace keyword defines a namespace or a namespace alias. Namespaces group declarations and help distinguish identically named entities; qualified access takes the form N::name.
noexcept either declares that an exception cannot escape a function or checks at compile time whether an expression is potentially throwing. These two uses combine in the conditional specification noexcept(noexcept(expression)).
`not` is an alternative spelling of the `!` operator in C++. The built-in operator reverses its operand's truth value and returns `bool`. It is neither bitwise negation nor a separate library function.
`not_eq` is a language-level alternative spelling of the C++ operator `!=`. It compares two operands using the same rules, precedence, and associativity; it requires neither a header nor a macro.
nullptr is a null pointer constant with the distinct type std::nullptr_t. Use it to initialize and compare pointers instead of the numeric literal 0, especially when calling overloaded functions.
The operator keyword forms names for overloaded operator functions, conversion functions, and literal operators. It lets you define how operations work on your own types, without changing operator precedence or grouping.
`or` is a language-level alternative spelling of the C++ operator `||`. For the built-in operator, the result is `bool`, and the right operand is evaluated only when the left operand is `false`. Do not confuse it with bitwise OR: `|` or `bitor`.
`or_eq` is an alternative spelling of the C++ `|=` operator. It combines the operands' bits using OR and stores the result in the left operand. It is a reserved language token, not a macro, and requires no header.
override requires a member function to override a virtual function from a base class. It catches declaration mistakes during compilation instead of allowing an inherited function to be hidden accidentally.