An object is a region of memory with type information
A variable is a named object
Functions
constexpr int name_of_function(string arg1 = 'default', ....) {
// code here
return 42;
}
Functions can be overloaded (same name, different parameters and same scope)
Small functions can be expanded during compilation with inline
If a function has a single return of a literal type, then we can use constexpr (implicitly inlined)
Exceptions
Some common exceptions defined in stdexcept, such as out_of_range, length_error
Use static_assert(expr, msg) for checking constant expressions, type assertions, low-level "certainties"
Macros
<cassert> → assert(expr) can be used to check for conditions that should not occur
can be silenced by #define NDEBUG
Classes
Can be defined using class, struct and union
A struct is simply a class with its members defaulted to public
A concrete class has its representation as part of its definition
In contrast, an abstract class hides its implementation from the user (decoupling representation from interface)
virtual ... foo() = 0; is often used to state a pure virtual function (i.e. derived classes must define said function)
= ... = delete; can be used to suppress any operation (e.g. move)
Functions defined in a class are inlined by default