fork download
  1. #include <iostream>
  2. using namespace std;
  3. struct A{};
  4. struct B{};
  5.  
  6. struct C: public A, public B{};
  7.  
  8. void f(A* a){
  9. cout << "a" << endl;
  10. }
  11. void f(B* b){
  12. cout << "b" << endl;
  13. }
  14.  
  15. int main() {
  16. C* c = new C();
  17. f(c);
  18. return 0;
  19. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:17:5: error: call of overloaded ‘f(C*&)’ is ambiguous
  f(c);
     ^
prog.cpp:8:6: note: candidate: void f(A*)
 void f(A* a){
      ^
prog.cpp:11:6: note: candidate: void f(B*)
 void f(B* b){
      ^
stdout
Standard output is empty