I have this sample code:
#include <iostream>
struct Interface1
{
virtual int getID()=0;
};
struct Interface2 : Interface1
{
virtual int add(int a,int b)=0;
};
struct Base1 : Interface1
{
virtual int getID() override { return 1; }
};
struct myClass: Interface2, Base1
{
virtual int add(int a,int b) override { return a+b; }
};
int main()
{
myClass c;
std::cout << c.add(0, 1) << "\n";
}
the idea is that myClass
is based on Interface2
, but uses Base1
as an implementation of Interface1. when I compile this code, I am getting this error:
getId is ambiguous.
How can I fix it?