What function does C++ write and call in an empty class?

The functions exist, but can be inlined.

When the compiler inlines the functions, it realizes they are no-ops, and there is no code generated.

What the book is saying, is true to an extent, the notional functions are created by the compiler, for inline and direct calling.

But the generated code is empty, so an optimizing compiler will then remove any evidence of the function (setting up a this pointer), and the functions will never be directly called.

The book is not really trying to explain the code generated, but the impact of creating a class, and the “hidden” functions it generates for normal operation.

Leave a Comment