using namespace std;
//-------------------
class Base
{
public:
virtual Base* afn(){cout<<"in base class\n";return this;}
};
class Sub:public Base
{
public:
virtual Sub* afn(){cout<<"in sub class\n";return this;}
};
void test(Base& s)
{
Base* p;
p=s.afn();
}
int main()
{
test(Base());
test(Sub());
}