当基类和派生类返回值为各自的指针或者引用时,但不可以为本身类类型
#include <iostream>
#include <string>
class A
{
public:
virtual A&(A*) showSelf()=0;
virtual A showSelf()=0;//error
};
class B:public A
{
public:
B&(B*) showSelf()
{std::cout << "B" << std::endl;return *this;}
B showSelf()
{std::cout << "B" << std::endl;return *this;}//error
};
int main(void)
{
B b;
b.showSelf();
return 0;
}