C++
    Overview
    Modern C++
    Language Concepts
    Operators
    Numerics
    Smart Pointers
    Containers
    Functions
    Memory Management
    Caveats
    Type Casting
    Trouble Shooting

C++ - Functions

Updated: 2022-02-12

non-member functions vs member functions

  • non-member functions, a.k.a. free functions: do not belong to any class.
  • member functions, a.k.a. methods(but "method" is not used in the C++ standard): part of a class or a struct.

Types of functions

  • overloaded functions
  • static functions
  • inline functions
  • operators
  • const member functions
  • virtual member functions
  • special class functions: default constructor, copy constructor, copy assignment operator, destructor; (since C++11) move constructor, move assignment operator
  • function templates
  • pure virtual function (= 0): subclasses have to implement this function, otherwise they are abstract. E.g. virtual std::string ToString( ) = 0;
  • variadic function templates (C++11)
  • constexpr functions (C++11)
  • consteval functions / immediate functions (C++20)
  • override and final for virtual functions (C++11)
  • = default and = delete functions (C++11)
  • lambdas (C++11)
  • coroutines (C++20)

Lambda

Use lambda expressions as anonymous functors.