/*
*Copyright(c) 2016.烟台大学计算机与控制工程学院
*ALL rights reserved.
*文件名称:app.cpp
*作者:赵子琳
*完成日期:2016年5月17日
*问题描述:阅读程序,写出执行结果
*/
#include <iostream>
using namespace std;
class Base
{
public:
Base(char i){cout<<"Base constructor.--"<<i<<endl;}
};
class Derived1:virtual public Base
{
public:
Derived1(char i,char j):Base(i){
cout<<"Derived1 constructor.--"<<j<<endl;
}
};
class Derived2:virtual public Base
{
public:
Derived2(char i,char j):Base(i){
cout<<"Derived2 constructor.--"<<j<<endl;
}
};
class MyDerived:public Derived1,public Derived2
{
public:
MyDerived(char i,char j,char k,char l,char m,char n,char x):
Derived2(i,j),Derived1(k,l),Base(m),d(n){
cout<<"MyDerived constructor.--"<<x<<endl;
}
private:
Base d;
};
int main()
{
MyDerived obj('A','B','C','D','E','F','G');
return 0;
}
第十周上机实践项目4:阅读程序,写出执行结果
最新推荐文章于 2023-08-11 09:39:26 发布
本文探讨了C++中多重继承下构造函数的执行顺序,通过具体实例展示了如何实现类之间的灵活组合。

3260

被折叠的 条评论
为什么被折叠?



