O'Reilly logo

SAMS Teach Yourself C++ in 10 Minutes SECOND EDITION by Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Inlining

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required