65,211
社区成员
发帖
与我相关
我的任务
分享#include <iostream.h>
class Base1{
protected:
int m;
public:
void Show(){cout<<m<<endl;}
};
class Base2{
protected:
int n;
public:
void Show(){cout<<n<<endl;}
};
class Derived:public Base1,public Base2{
public:
void Set(int x,int y){m=x;n=y;}
void Show(){cout<<cout<<m<<"\n"<<n<<endl;} //重定义
};
void main(){
Derived Obj;
Obj.Set(45,87);
Obj.Show();
Obj.Base1::Show();
Obj.Base2::Show();
}