1、思维导图
https://www.zhixi.com/view/9e899ee0
2、作业
#include <iostream>
using namespace std;
class Sofa
{
private:
string motion;
public:
Sofa()
{
cout << "Sofa:无参函数" << endl;
}
Sofa(string m):motion(m)
{
cout << "Sofa:有参函数" << endl;
}
void show()
{
cout << motion << endl;
}
};
class Bed
{
private:
string motion;
public:
Bed()
{
cout << "Bed:无参函数" << endl;
}
Bed(string m):motion(m)
{
cout << "Bed:有参函数" << endl;
}
void show()
{
cout << motion << endl;
}
};
class Sofa_bed:public Sofa,public Bed
{
private:
string color;
public:
Sofa_bed()
{
cout << "Sofa_bed:无参函数" << endl;
}
Sofa_bed(string s,string b,string c):Sofa(s),Bed(b),color(c)
{
cout << "Sofa_bed:有参函数" << endl;
}
void show()
{
Sofa::show();
Bed::show();
cout << color << endl;
}
};
int main()
{
Sofa_bed s1;
Sofa_bed s2("sit","sleep","red");
s2.show();
return 0;
}