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