g++ warnings, inline virtual function used but not defined

c++, g++

Solution

From http://en.cppreference.com/w/cpp/language/inline

The definition of an inline function must be present in the translation unit where it is called.

If you are going to define the function in a .cpp file, you must remove the `inline` specifier from the .h file.

Problem

I'm currently having a problem with a g++ warnings I cannot get rid off. My code is working perfectly but this warning keeps poping up: ChildModel.h:136:24: warning: inline function virtual int ChildModel::getLinkCost(const Link&) const used but never defined [enabled by default] I currently found this post on S.O, with the same problem, but the answer is specific to the library (defining something) so it doesn't work for me. My code is as follow: ``` class Model { public: virtual inline int getLinkCost(Link const& link) const; }; class ChildModel: public Model { public: /** Warning on the line bellow: **/ virtual inline int getLinkCost(Link const& link) const; }; ``` The only function redefined by `ChildModel` is `Model::getLinkCost`, and the `Model::getLinkCost` method is only called by a method of `Model`. All the method are defined in a C++ file `Model.cpp`.

Original source