I have the code which is equivalent to this one:
class X {};
class Y {};
template< typename T>
class C {
public:
virtual T * foo() = 0;
};
class A : public C< X> {
public:
X * foo() {};
};
class B : public A {};
class D : public B, public C< Y> {
public:
Y * foo() {}; //this is the only one method I need here. Not A::foo!
};
I got this errors:
error: invalid covariant return type for 'virtual Y* D::foo()'
Y * foo() {};
^
and:
error: overriding 'virtual X* A::foo()'
X * foo() {};
^
I believe I could write something in class B or D to prevent A::foo from inheriting, but I don't know what. Maybe there is some feature to rename conflict names in C++?
PS> I can't use C++11, only good old C++98.