inline specifier |
Inline function specifier
|
function-specifier := inline
|
|
The inline function specifier can be used with any
function or member function to hint to the compiler that the function
should be expanded inline at the point of call. The compiler is free
to ignore the hint. The compiler is also free to expand functions
inline that are declared without the inline
specifier, so long as this does not affect the semantics of the
program.
An inline function must be defined in the same source file where it
is used, before it is used. An inline function can be defined in more
than one file (unlike other functions); the definition in every file
must be the same.
A member function that is defined within a class definition is
implicitly declared inline.
Example
struct point {
inline point(int x, int y) : x_(x), y_(y) {} // Redundant
inline point( );
private:
int x_, y_;
};
inline point::point( ) : x_(0), y_(0) {}
See Also
class, declaration,
function, type, Chapter 5
|