Back to slide -- Keyboard shortcut: 'u'        next -- Keyboard shortcut: 'n'          multiple-inh/ambiguities/amb-1.cc - Ambiguity - the compiler locates the problem.Lecture 5 - slide 18 : 40
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());
}