I have a problem with calling an inherited method. Probably I miss some virtual, const or & but I cannot find where
I have a base class Classifier with one "real" and one virtual function, the "real" function calls the virtual one. The child class MyClassifier defines the virtual inherited methon. Now when I call the "real" class on the MyClassifier object, I get compiler error.
class Classifier {
public:
bool classify(const Image& ii)
{
return classify(ii, ii.getRect());
}
virtual bool classify(const Image& ii, const rect_t& rect) const = 0;
};
class MyClassifier : public Classifier {
public:
bool classify(const Image& ii, const rect_t& rect) const;
};
bool
MyClassifier::classify(const Image& ii, const rect_t& rect) const
{
// do stuff...
}
The calling code is:
// main...
MyClassifier c;
Image some_image;
c.classify(some_image);
And the error:
error: no matching function for call to ‘MyClassifier::classify(const Image&) const’
note: candidate is:
note: virtual bool MyClassifier::classify(const Image&, const rect_t&) const
note: candidate expects 2 arguments, 1 provided
classifycalling tits 2-parameter version for each inherited class. For me it can be with or withoutvirtual. Without even better as I won't getvtableperformance penalty