#include <iostream>
#include <stdint.h>
using namespace std;
class BaseClass
{
public:
BaseClass()
{
cout << "Base Class Constructor" << endl;
}
~BaseClass()
{
cout << "Base Class Destructor" << endl;
}
};
class DeriveClassA : virtual public BaseClass
{
public:
DeriveClassA()
{
cout << "DeriveClassA Class Constructor" << endl;
}
~DeriveClassA()
{
cout << "DeriveClassA Class Destructor" << endl;
}
};
class DeriveClassB : virtual public BaseClass
{
public:
DeriveClassB()
{
cout << "DeriveClassB Class Constructor" << endl;
}
~DeriveClassB()
{
cout << "DeriveClassB Class Destructor" << endl;
}
};
class DeriveDeriveClass : virtual public DeriveClassA, virtual public DeriveClassB
{
public:
DeriveDeriveClass()
{
cout << "DeriveDeriveClass Class Constructor" << endl;
}
~DeriveDeriveClass()
{
cout << "DeriveDeriveClass Class Destructor" << endl;
}
};
int main()
{
DeriveDeriveClass obj;
return 0;
}
C++:虚继承
猜你喜欢
转载自blog.csdn.net/xikangsoon/article/details/109092919
今日推荐
周排行