#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 ; }
运行结果:
时间: 2024-10-12 13:41:50