class Base {
public:
virtual void myFunc(double a, double b) { };
virtual void myFunc(double a) { };
};
class Derived : public Base {
public:
virtual void myFunc(double a) { return this->myFunc(a, 0.0); };
}; // ^^^^^^^^^^^^^^^^^^^^
The previous code won't compile : error C2660: 'Derived::myFunc' : function does not take 2 arguments
Apparently the compiler cannot see that I'm trying to call the function defined in Base class, or any function that overrides it. On the other hand, the following code compiles ok:
class Base {
public:
virtual void myFunc2(double a, double b) { };
virtual void myFunc(double a) { };
};
class Derived : public Base {
public:
virtual void myFunc(double a) { return this->myFunc2(a, 0.0); };
};
I think what i'm trying to do in the first example is legal C++, so is this a bug in the VS2010 compiler? I have the same results with VS2008
thanks
edit : a workaround I found is to use
virtual void myFunc(double a) { return ((Base*)this)->myFunc(a, 0.0); };
but I'm not 100% sure it has the exact same effect, can anyone confirm?