充分意識到,我所問的問題超出了C++標準的範圍,我很想知道爲什麼GCC會拋出兩次相同的錯誤?我知道爲什麼錯誤在那裏,但我期待着理解爲什麼錯誤消息中的重複。爲什麼錯誤發出兩次?
#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(){}
錯誤:
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()
GCC版本4.3.4 – Chubsdad 2010-08-20 04:16:03
版本4.2.1和4.5.1之間的字符串「對%s的引用不明確」的字符串附近發生了哪些變化? – 2010-08-20 04:17:31