1

The following code gives error that request for member fcn1 is ambiguous. Why is this happening?

class Base1 {
public:
  void fcn1(int x) {}
};

class Base2 {
public:
  void fcn1(int x, int) {}
};

class D: public Base1, public Base2 {
};


int main()
{
  D* d = new D;
  d->fcn1(1);
}

Putting the following in class D makes it work

public:
  using Base1::fcn1;
  using Base2::fcn1;
szli
  • 36,893
  • 11
  • 32
  • 40

0 Answers0