小弟有一个C++的问题请指教一下啊!
#include <iostream.h>
#include <stdio.h>
class Base
{
public:
virtual Base* afn()
{
cout<<"This is Base class. \n";
return this;
}
};
class SubClass:public Base
{
public:
virtual SubClass* afn()
{
cout<<"This is SubClass. \n";
return this;
}
};
void test(Base& x)
{
Base* b;
b=x.afn();
}
void main()
{
Base bc;
SubClass sc;
test(bc);
test(sc);
cin.get();
}
帮我看看哪里有错误啊,我找不到啊,谢谢!