The function specifier inline is used to make a suggestion to the compiler to incorporate the code of a function into the code at the point of the call. Instead of creating a single set of the function instructions in memory, the compiler is supposed to copy the code from the inline function directly into the calling function. However, a standards-compliant compiler may ignore this suggestion for better optimization.
The remainder of this section pertains to C++ only.
Both regular functions and member functions can be declared inline. A member function can be made inline by using the keyword inline, even if the function is declared outside of the class declaration.
The keywords virtual and explicit are used only in C++ function declarations as function specifiers.
The function specifier virtual can only be used in nonstatic member function declarations.
The function specifier explicit can only be used in declarations of constructors within a class declaration. It is used to control unwanted implicit type conversions when an object is being initialized. An explicit constructor differs from a non-explicit constructor in that an explicit constructor can only construct objects where direct initialization syntax or explicit casts are used.
Related References