I have the following class defined in a foo.h
header file
class Foo {
public:
inline int Method();
};
inline int Foo::Method() { // Imple
It may be confusing, but you should not think of the purpose of inline
to make the compiler inline a function. (Modern compilers are way smarter than you in regards to when a function should be inlined or not anyway).
No, the real purpose of inline
is to tell the linker to not worry about multiple definitions of the function. If you put the definition of a (non-member) function in a header, you should mark it inline
to avoid linker errors.