Member functions defined within a class declaration are considered inline functions. Calls to these functions are usually replaced with the actual code defined in the function body.
A member or nonmember function defined outside the class declaration can be specified as inline by using the inline keyword. For example:
class Rect
{
public:
inline void Set( unsigned x1, unsigned y1,
unsigned x2, unsigned y2 );
private:
unsigned private_x1, private_y1, private_x2, private_y2;
};
void Rect::Set( unsigned x1, unsigned y1,
unsigned x2, unsigned y2 );
{
private_x1 = x1;
private_y1 = y1;
private_x2 = x2;
private_y2 = y2;
}
Notice that the definition of Rect::Set is outside the class declaration, but it is still an inline function.
Inline functions declared inside class declarations behave as if they were defined just after the class declaration. Therefore, because the class is considered completely defined, inline functions can access the class name and all class members.