fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. template <typename T> T square(T v) { return v*v; }
  7. int f(int v) { return square(v); }
  8. double f(double v) { return square(v); }
  9.  
  10. class Shit
  11. {
  12.  
  13. };
  14.  
  15. int main()
  16. {
  17.  
  18. cout << f(4) << endl;
  19. cout << f(5.7) << endl;
  20.  
  21. Shit s;
  22. cout << f(s) << endl;
  23.  
  24. return 0;
  25. }
  26.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:22:16: error: no matching function for call to ‘f(Shit&)’
     cout << f(s) << endl;
                ^
prog.cpp:22:16: note: candidates are:
prog.cpp:7:5: note: int f(int)
 int f(int v) { return square(v); }
     ^
prog.cpp:7:5: note:   no known conversion for argument 1 from ‘Shit’ to ‘int’
prog.cpp:8:8: note: double f(double)
 double f(double v) { return square(v); }
        ^
prog.cpp:8:8: note:   no known conversion for argument 1 from ‘Shit’ to ‘double’
stdout
Standard output is empty