Fully aware that the question I am asking is outside the purview of C ++ Standard, I am curious to know why GCC throws the same error twice? I know why there is an error, but I am looking forward to understand why duplication in the error message.
#include <iostream>
using namespace std;
struct A{
virtual void f1() = 0;
};
struct B : A{
};
struct C : A{
void f1(){}
};
struct D : C, B{
void f2(){f1();}
};
int main(){}
Error:
prog.cpp: In member function ‘void D::f2()’:
prog.cpp:16: error: reference to ‘f1’ is ambiguous
prog.cpp:5: error: candidates are: virtual void A::f1()
prog.cpp:12: error: virtual void C::f1()
prog.cpp:16: error: reference to ‘f1’ is ambiguous
prog.cpp:5: error: candidates are: virtual void A::f1()
prog.cpp:12: error: virtual void C::f1()
source
share