fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int ff(int i) { return i; }
  6. int fs(int i) { return i; }
  7.  
  8. struct X
  9. {
  10. friend X ff(X x);
  11. static X fs(X x);
  12. };
  13. X ff(X x) { return x; }
  14. X X::fs(X x) { return x; }
  15.  
  16. template<class T>
  17. T ff2(T t) { return ff(t); }
  18.  
  19. template<class T>
  20. T fs2(T t) { return fs(t); }
  21.  
  22. int main() {
  23. int i = 0;
  24. X x;
  25.  
  26. ff2(i);
  27. ff2(x);
  28.  
  29. fs2(i);
  30. fs2(x);
  31. return 0;
  32. }
  33.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In instantiation of ‘T fs2(T) [with T = X]’:
prog.cpp:30:10:   required from here
prog.cpp:20:23: error: cannot convert ‘X’ to ‘int’ for argument ‘1’ to ‘int fs(int)’
 T fs2(T t) { return fs(t); }
                     ~~^~~
stdout
Standard output is empty