Dave wrote:
I have one method of a class calling another method (both private, though
that shouldn't matter). The method and its enclosing class are declared in
a .h file and the method is defined in a corresponding .cpp file. If I mark
the method as inline (either in the declaration alone, the definition alone
or both), I get a link error. If I do not mark the method as inline,
everything is fine. Can anybody think of a plausible explanation for this
behavior? My platform is VC++ 7.1.
If you declare the implementation inline and put it into a source file,
you will get errors when trying to call it from another source file.
If you put the implementation into a header but outside the class
definition and _not_ mark it inline, you will get errors if the header
is included into more than one source.
Why all the games? A simple thing to remember is "if a member function
is defined in the header, it needs to be declared 'inline', otherwise
it mustn't". Follow that rule and the worst you can do is declare it
'inline' when it's already inline (defined in the class definition).
Victor