![]() ![]() ![]() ![]() | Ambiguity resolution in the client of C. | Lecture 4 - slide 15 : 24 Program 2 |
// How to use the scope operator to resolve the ambiguity. #include <iostream> #include <string> using namespace std; class A { public: int data; int operation(){ cout << "A: operation" << endl; return data; } }; class B { public: int data; int operation(){ cout << "B: operation" << endl; return data; } }; class C: public A, public B{ }; int f(C* c){ int r1 = c->A::operation(), r2 = c->B::operation(); return r1 + r2; } int main(){ f(new C()); // OUTPUT: // A: operation // B: operation }