Subject basically sums it up. I have a class and the .h is code free and in the .cpp file for that class I use inline on the function definitions I want inlined. Main.cpp includes "myclass.h" and does some tests on the class. Everytime I call a function I have specified as inline I get a LNK2019 unresolved external. If I remove the inline specifier the code compiles and runs perfectly but not as quick as I'd like. So how do you keep .h code free and tell the compiler (msvc7) to inline the functions? Do the inline functions have to be in the header file ? I checked help files but they were useless only showing single-file code.
Hungarian notation is the bane of self documenting code.
Forget all fancy tricks with operator precedence. Code should be easily readable.
May the BOOST be with you.
Good free E-Books thanks to Bruce Eckel.
Originally posted by Improving
Do the inline functions have to be in the header file ?
short answer, yes. the body of the inlined function has to be in the same scope as the place where it gets inlined. (when in doubt, check with the standard: 3.2.4. An inline function shall be defined in every translation unit in which it is used)