#include<iostream>
class base{
public:
base(){std::cout<<"In base";}
};
class dv1:virtual private base {
public:
dv1(){std::cout<<"In DV1";}
};
class dv2:virtual private base {
public:
dv2(){std::cout<<"In DV2";}
};
class drv : public dv1, public dv2 {
public:
drv() {std::cout<<"Why is this working";}
};
int main() {
drv obj;
return 0;
}
不是在虚拟继承的情况下,调用构造函数是大多数派生类的责任吗?注意:这里的 base 是虚拟和私人继承的。