#include <iostream> using namespace std; struct T4 { int foo; T4(): foo(4) {}}; struct T3: public T4 {}; struct T2: public T4 { int foo; T2(): foo(2) {}}; struct T1: public T2, public T3 {}; int main(int, char const *[]){ const T1 t1; cout << t1.foo << endl;}
Standard input is empty
prog.cpp: In function ‘int main(int, const char**)’: prog.cpp:25:13: error: request for member ‘foo’ is ambiguous cout << t1.foo << endl; ^~~ prog.cpp:7:6: note: candidates are: int T4::foo int foo; ^~~ prog.cpp:15:6: note: int T2::foo int foo; ^~~
Standard output is empty
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!