#include
using namespace std;
class Wangyiyun
{
private:
string vip;
public:
Wangyiyun()
{ cout << "网易云的无参构造函数" << endl; }
Wangyiyun(string v):vip(v)
{ cout << "网易云的有参构造函数" << endl; }
void show()
{ cout << vip << endl; }
};
class Txqq
{
private:
string supervip;
public:
Txqq()
{ cout << "QQ音乐的无参构造函数" << endl; }
Txqq(string s):supervip(s)
{ cout << "QQ音乐的有参构造函数" << endl; }
void show()
{ cout << supervip << endl; }
};
class Dayuanzhong : protected Wangyiyun, protected Txqq
{
private:
string characteristic;
public:
Dayuanzhong()
{ cout << "大冤种的无参构造函数" << endl; }
Dayuanzhong(string v, string s, string c):Wangyiyun(v), Txqq(s), characteristic(c)
{ cout << "大冤种的有参构造函数" << endl; }
void show()
{
Wangyiyun::show();
Txqq::show();
cout << "大冤种" << endl;
}
};
int main()
{
Dayuanzhong c("黑胶vip", "豪华绿钻", "人傻钱多");
c.show();
return 0;
}
运行结果: