5.9 INLINE FUNCTIONS (within a class)

In the earlier chapter, we have seen the use of keyword inline with global functions. It tells the compiler to replace every function call in a source code by actual code of that function. We can request the compiler for inline expansion for member functions too. Let us study inline functions within a class. This can be done in two different styles.

Style1: When a member function is fully defined in the class definition for example.

Syntax:

class SomeClass    {   <datatype> <function_name>(<parameters>)        { <statements>; }    }

Here we combine function declaration and definition. Note the absence of keyword inline. Such functions are inline by default. It should be noted that the function definition ...

Get Object Oriented Programming with C++, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.