fork download
  1. #include <iostream>
  2.  
  3. template <class T>
  4. T myMax(T& t1, T& t2)
  5. {
  6. return t1 < t2 ? t2 : t1;
  7. }
  8.  
  9. int main()
  10. {
  11. int result = myMax(3, 4);
  12. return result;
  13. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:11:28: error: invalid initialization of non-const reference of type ‘int&’ from an rvalue of type ‘int’
     int result = myMax(3, 4);
                            ^
prog.cpp:4:3: note:   initializing argument 1 of ‘T myMax(T&, T&) [with T = int]’
 T myMax(T& t1, T& t2)
   ^~~~~
stdout
Standard output is empty