IIRC - the definition of an inline function has tp be available to the compiler at the time you attempt to reference/call the function.
This means that when compiling Parser.cc it need to be available - so it's no good putting it in IOSERs.cpp file because that file is not available at that time .
Put the function in IOSERs.h because you #include that file in Parser.cc
1) put the function body in the class itself
2) put the function body in the header below the class
1 2 3 4 5 6 7 8 9 10
class MyClass
{
staticbool Option1() { returntrue; } // implicitly inlined
staticbool Option2();
};
inlinebool MyClassOption2() // inlined (note it must be in the header)
{
returntrue;
}
A 3rd approach, if you plan on having many inline functions and don't want them in the class body, is to make another header and include that from your class header:
1 2 3 4 5 6 7 8 9 10 11 12
// in myclass.h
#ifndef __MYCLASS_H_INCLUDED__
#define __MYCLASS_H_INCLUDED__
class MyClass
{
staticbool Option3();
};
#include "myclass.hpp" // or "myclass_inline.h", or whatever
#endif
1 2 3 4 5 6
// in myclass .hpp
inlinebool MyClass::Option3()
{
returntrue;
}
Options 2 and 3 are benefitial because they allow you to avoid circular dependency issues if these functions use other classes.