Inline functions not linking successfully

I am writing the following code in MS Visual C++ version 6.0:

class PA_node {
     bool conflict_removed;
     bool conflict_already_removed() const;

And the implementation is (it is of course not placed in the same .h file as the class declaration but in a separate .cpp file):

inline bool PA_node::conflict_already_removed() const {
      return conflict_removed;

Please note the "inline" prefix in the function defintion. Now my problem is that when I try to link this code the linker complains that it can't find the function definition:

error LNK2001: unresolved external symbol "public: bool __thiscall PA_node::conflict_already_removed(void)const " (?conflict_already_removed@PA_node@@QBE_NXZ)

What puzzles me is that the code looks perfectly okay and also, when I remove the "inline" prefix it links without hitch. Also, the linker is linking some other "inlined" functions without problem and it is complaining about others and to me this sounds very random. What is going wrong here? Or is it just a bug in MS Visual C++.

Please help
Who is Participating?
AlexFMConnect With a Mentor Commented:
Put inline function to h-file. Suppose that C++ compiler compiles some file (let's sey client.cpp) which calls PA_node::conflict_already_removed function. Since this function is inline, this call must be replaced with inline implementation. But compiler doesn't see this implementation because it is in another cpp file. In this case compiler defines this call as external link. This link cannot be resolved because function is defined as inline in another cpp file.
Notice that compiler doesn't care whether inline function is defined in h or cpp file - this is precompiler work.
gurry_uorAuthor Commented:
I tried that and it works. But I still, some other member functions of the same class which are placed in separate .cpp file and are "inlined" are linking perfectly. Only this particular one wasn't. What does that mean? Is it that the compiler is not actually inlining the other functions (since the compiler has the option of ignoring the 'inline' keyword)?

Secondly, if one is always required to place 'inlined' functions in the header file itself, most people would never use the 'inline' keyword because this will force them to place their member function implementations in header file and that would mean they are revealing their implementation to everyone, which most people don't want. So how does it work?

Thanks for your answer.
gurry_uorAuthor Commented:
Oh I get it. The other functions which are linking succefully haven't been called anywhere yet. I am sorry for my stupid second question. So thanks Alex. I accept your answer.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.