C++之多继承

来源:互联网 发布:黑客帝国3:矩阵革命mp4 编辑:程序博客网 时间:2024/06/05 08:43
#include <iostream>using namespace std ; class AA{public:int a ; void Say_hello(void){cout << "this is AA " << endl ; }};class BB{public:int b ; void Say_hello(void){cout << "this is BB " << endl ; }};//多继承 class CC  : public AA , public BB{public:int d ; void Say_hello(void){cout << "this is CC " << endl ; }};int main(void){CC  aa ; aa.Say_hello();aa.AA::Say_hello();aa.BB::Say_hello();aa.CC::Say_hello();cout << "Size AA : " << sizeof(AA) << endl ; cout << "Size BB : " << sizeof(BB) << endl ; cout << "Size CC : " << sizeof(CC) << endl ; }

运行结果:


1 0