Back to notes -- Keyboard shortcut: 'u'        next -- Keyboard shortcut: 'n'  Slide program -- Keyboard shortcut: 't'    Ambiguity - the compiler locates the problem.Lecture 4 - slide 15 : 24
Program 1
// A very simple illustration of an ambiguity in 
// a multiple-inheritance situation.

#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){
  return c->operation();  
                          // Compiler: 
                          // error: request for member operation is ambiguous
                          // error: candidates are: int B::operation()
                          // error:                 int A::operation()
}


int main(){
  f(new C());
}