fork(1) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6. struct T4 {
  7. int foo;
  8. T4(): foo(4) {}
  9. };
  10.  
  11. struct T3: public T4 {
  12. };
  13.  
  14. struct T2: public T4 {
  15. int foo;
  16. T2(): foo(2) {}
  17. };
  18.  
  19. struct T1: public T2, public T3 {};
  20.  
  21.  
  22. int main(int, char const *[])
  23. {
  24. const T1 t1;
  25. cout << t1.foo << endl;
  26. }
  27.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
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;
      ^~~
stdout
Standard output is empty