#include <iostream> using namespace std; class Base{ public: Base(){ cout << "Base called..." << endl; } void print() { cout << "Base ::print()" << endl; } }; class Sub{ public: Sub(){ cout << "Sub called..." << endl; } void print(){ cout << "Sub print...." << endl; } }; class Child: public Base, public Sub{ public: Child(){ cout << "Child called..." << endl; } }; int main(void){ Child c; //c.print();报错,这里c类中的有两个print()函数,它们的地位相同 c.Base::print(); c.Sub::print(); return 0; }
本文出自 “12208412” 博客,请务必保留此出处http://12218412.blog.51cto.com/12208412/1867815
原文:http://12218412.blog.51cto.com/12208412/1867815