#include <iostream>
using namespace std;
class bed
{
private:
string sleep;
public:
//无残构造
bed() {}
//有参构造
bed(string sleep):sleep(sleep)
{}
void show()
{
cout <<sleep << endl;
}
};
class sofa
{
private:
string sit;
public:
sofa() {}
sofa(string sit):sit(sit)
{}
void show()
{
cout <<sit << endl;
}
};
class bed_sofa:public bed,public sofa
{
private:
string color;
public:
bed_sofa() {}
bed_sofa(string sleep,string sit,string color):bed(sleep),sofa(sit),color(color)
{
}
};
int main()
{
bed_sofa A("1","2","3");
A.sofa::show();
A.bed::show();
cout << "Hello World!" << endl;
return 0;
}
1011hw
最新推荐文章于 2024-11-12 12:29:51 发布