#include<iostream>using namespace std;class A{public:void virtual f(){cout<<"A"<<endl;}};class B:public A{public:void virtual f(){cout<<"B"<<endl;}};void main(){ B *pa=new A(); }
提示是错误
主函数改为:
void main(){ A *pa=new B();}
正确