C++ offers an easy way to gain speed at the cost of space.
A sophisticated object-oriented program may make millions of function calls per second. Even if each function call takes a tiny amount of time, reducing the overhead from such calls can sometimes make the difference between acceptable and unacceptable performance.
If testing indicates that reducing function calls can help performance (and it is usually only a tiny minority of calls that are repeated often enough to be usefully optimized), then inlining lets you eliminate function call overhead at the price of increased program size.
There are two ways to inline. The simplest is to put the function implementation in the class declaration, as in this (non-template) version of ...