<sub>NB This is not a question about how to use inline functions or how they work, more why they are done the way they are.</sub>The declaration of a class member function does not need to define a function as `inline`, it is only the actual implementation of the function. For example, in the header file:<!-- language: lang-cpp --> struct foo{ void bar(); // no need to define this as inline }So why does the inline implementation of a classes function *have* to be in the header file? Why can't I put the inline function the `.cpp` file? If I where to try to put the inline definition in the `.cpp` file I would get an error along the lines of:<!-- language: none --> error LNK2019: unresolved external symbol "public: void __thiscall foo::bar(void)" (?bar@foo@@QAEXXZ) referenced in function _main 1>C:\\Users\\Me\\Documents\\Visual Studio 2012\\Projects\\inline\\Debug\\inline.exe : fatal error LNK1120: 1 unresolved externals
If multiple source code files require the use of the function, they will not know that the function is to be inlined if the inline keyword appears in the source *.cpp rather than the header.