河南成教 / 面向对象程序设计
12[分析题]
class Base{ protected: int a;public:Base(int x,){a=x;}virtual void show(){ cout<<“base”<<endl; cout<<a<<“ “<<endl;}};class my_class:public Base{int b:public: my_class(int x,int y): Base(x){ b=y;}void show(){ cout<<“my_class” <<“a=”<<a <<“b=”<<b;}};void main{Base ma(50),*mp;my_class mb(10,20);mp=&mb;mp->show();mp=&ma;mp->show();}
12[分析题]
class Base{ protected: int a;public:Base(int x,){a=x;}virtual void show(){ cout<<“base”<<endl; cout<<a<<“ “<<endl;}};class my_class:public Base{int b:public: my_class(int x,int y): Base(x){ b=y;}void show(){ cout<<“my_class” <<“a=”<<a <<“b=”<<b;}};void main{Base ma(50),*mp;my_class mb(10,20);mp=&mb;mp->show();mp=&ma;mp->show();}
参考答案:
佳题速递: