#includeusing 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 ; }
運行結果: