Possible Duplicate:
it is possible to change return type when override a virtual function in C++?C++不同的返回類型重寫功能比基類
我得到錯誤:
error: conflicting return type specified for âvirtual bool D::Show()
7: error: overriding âvirtual void A::Show()"
當我編譯我的代碼。代碼是:
class A
{
public:
virtual void Show()
{
std::cout<<"\n Class A Show\n";
}
};
class B : public A
{
public:
void Show(int i)
{
std::cout<<"\n Class B Show\n";
}
};
class C
{
public:
virtual bool Show()=0;
};
class D :public C, public B
{
public:
bool Show(){
std::cout<<"\n child Show\n";
return true;}
};
int main()
{
D d;
d.Show();
return 0;
}
我想使用類C中的Show()函數。我的錯誤在哪裏?
http://stackoverflow.com/a/4222307/1231073 – sgarizvi