多重继承
多重继承与多层继承不同,通俗点讲就是有多个爹妈的意思,现实中的比如三国时期的吕布,史称"三姓家奴"
#include <iostream>
//幕爸
class MFather{
protected:
int handsome;//英俊潇洒程度
};
//幕妈
class MMother{
protected:
int goodness;//勤劳善良程度
};
//小小幕
class Mchild:public MFather,public MMother{
protected:
int imp;//淘气
};
int main(int argc, const char * argv[]) {
std::cout<<sizeof(MFather)<<std::endl; //4
std::cout<<sizeof(MMother)<<std::endl; //8 =4 +4
std::cout<<sizeof(Mchild)<<std::endl; //12 =4+4+4
return 0;
}