fork download
  1. class A
  2. {
  3. public:
  4.  
  5. A(int ) // not giving the int parameter a name because we don't use it
  6. {
  7. }
  8. };
  9.  
  10. class B
  11. {
  12. public:
  13.  
  14. explicit B(int )
  15. {
  16. }
  17. };
  18.  
  19. void func_a(A )
  20. {
  21. }
  22.  
  23. void func_b(B )
  24. {
  25. }
  26.  
  27. int main()
  28. {
  29. func_a(A(100)); // works
  30. func_a(200); // works!
  31. func_b(B(100)); // works
  32. func_b(200); // doesn't work!
  33. }
  34.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:32:15: error: could not convert ‘200’ from ‘int’ to ‘B’
     func_b(200); // doesn't work!
               ^
stdout
Standard output is empty