64,654
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
using namespace std;
class Base
{
public:
Base(int i) { cout << "Base" << i << endl; }
~Base () { }
};
class Base1: virtual public Base
{
public:
Base1(int i, int j=0) : Base(j) { cout << "Base1" << i << endl; }
~Base1() {}
};
class Base2: virtual public Base
{
public:
Base2(int i, int j=0) : Base(j) { cout << "Base2" << i << endl; }
~Base2() {}
};
class Derived : public Base2, public Base1
{
public:
Derived(int a, int b, int c, int d) : mem1(a), mem2(b), Base1(c),
Base2(d), Base(a)
{ cout << b; }
private:
Base2 mem2;
Base1 mem1;
};
void main() { Derived objD (1, 2, 3, 4); }