fork(2) download
  1. #include <stdio.h>
  2.  
  3. class A
  4. {
  5. public:
  6. };
  7.  
  8. class B
  9. {
  10. public:
  11. B(const A &a) { printf("const A&\n");}
  12. B(A a){ printf("A\n");}
  13. };
  14.  
  15. int main(void) {
  16.  
  17. A a;
  18. const A ac;
  19. B b(a);
  20. B b1(ac);
  21. B b2(A());
  22.  
  23. return 0;
  24. }
  25.  
Compilation error #stdin compilation error #stdout 0s 4576KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:19:10: error: call of overloaded ‘B(A&)’ is ambiguous
     B b(a);
          ^
prog.cpp:12:5: note: candidate: B::B(A)
     B(A a){ printf("A\n");}
     ^
prog.cpp:11:5: note: candidate: B::B(const A&)
     B(const A &a) { printf("const A&\n");}
     ^
prog.cpp:8:7: note: candidate: constexpr B::B(const B&)
 class B
       ^
prog.cpp:8:7: note: candidate: constexpr B::B(B&&)
prog.cpp:20:12: error: call of overloaded ‘B(const A&)’ is ambiguous
     B b1(ac);
            ^
prog.cpp:12:5: note: candidate: B::B(A)
     B(A a){ printf("A\n");}
     ^
prog.cpp:11:5: note: candidate: B::B(const A&)
     B(const A &a) { printf("const A&\n");}
     ^
prog.cpp:8:7: note: candidate: constexpr B::B(const B&)
 class B
       ^
prog.cpp:8:7: note: candidate: constexpr B::B(B&&)
stdout
Standard output is empty