When you mark a function inline, you ask the compiler to replace any call to that function with the contents of the function itself, instead of making that call. In most cases, that also means the function is not generated as a "out-of-line" function at all: there is no GetStrength function in your program.
When calling an inline function, it is necessary for the compiler to have access to the body of the function, so that the replacement can happen. That means you cannot bury a function in a single .cpp file, but really have to make the function code available to any .cpp file that calls that function. The simplest and most obvious way to do so is to put the whole inline function into a header file, which will get included in any translation unit that requires the function (remember that putting something in a header file and then including that header is strictly equivalent to manually writing out all of the header's contents in the file that includes the header - that's how preprocessor #include directives work).
In your case, you declared the functions in your class, telling the compiler that it was not an error to try and call them, but you never did provide the body for them. The compiler therefore assumed, when it processed main.cpp, that the function would be provided by another translation unit that would eventually get linked. However, in Creature.cpp, you did provide those functions as inline functions. Since C++ uses a separate compilation model, when processing Creature.cpp, the compiler is completely unaware of whatever needs main.cpp might have. It notices the functions have been marked inline and yet are never used
in Creature.cpp -- it therefore just discards them completely. Once both files are compiled, the linker tries to reconciliate all the function calls, but never finds an actual GetStrength() function, and thus raises a stink.
You have several solutions to this problem. The first is to move the inline functions to the header file that contains the class definition. Any translation unit making use of the class is going to include the header anyway so, that way, they'll get the inline functions too. There are two ways you can do that. You can either simply cut and paste your code back to the header file or, given that member functions which are
defined within a class definition are implicitely inline, you could turn the member function declarations into definitions:
class Foo{ int bar;public: // int GetBar(); <--- That's a declaration int GetBar() { return bar; } // <--- That's a definition};
The other solution, simpler but probably less satisfying for mere "accessor" functions (which, for such a simple class are in my opinion a
terrible idea) is to just drop the inline. That way, actual functions will be generated and thus found by the linker.
edit: Bleh. Too slow... Curse you SiCrane, and your little dog too. [razz]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan