1. The first thing to note is that an inline function has a static link (static linkage) and is not visible to anyone other than the file. 2. Compilation is a sub-module (different compilation modules refer to different files), using # include to include the header file of the class, in the preprocessing phase will be replaced by text. If a function of the class is defined in the. h file at this time, the file containing the inlcude will be compiled with the function definition written to the. Symtab symbol table in the target file of the compilation module. Now, if the function definition in the. h class is not inline, the function symbol symbol in the. Symtab is exposed outward. If multiple files include the header files of the class, the function symbol is exposed in their respective target files. This will cause a redefinition error to occur during the connection process. So, we'll see in the deep C + + object model that the compiler constructor the default constructor when compositing the default, destructor,assignment copy operator is done with inline, and if the function is too complex to fit inline, a explicit non-inline static instance is synthesized.
Why a function defined in a class is inline by default