fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template <typename T>
  5. T myMax(T a, T b) {
  6. return (a > b) ? a : b;
  7. }
  8.  
  9. int main() {
  10. cout << "myMax(3, 7) = " << myMax(3, 7) << endl;
  11. cout << "myMax(3.5, 1.2) = " << myMax(3.5, 1.2) << endl;
  12. cout << "myMax('a', 'z') = " << myMax('a', 'z') << endl;
  13. cout << "myMax(999999999LL, 1000000000LL) = " << myMax(999999999LL, 1000000000LL) << endl;
  14. cout << "myMax(true, false) = " << myMax(true, false) << endl;
  15.  
  16. return 0;
  17. }
Success #stdin #stdout 0s 5324KB
stdin
7
stdout
myMax(3, 7) = 7
myMax(3.5, 1.2) = 3.5
myMax('a', 'z') = z
myMax(999999999LL, 1000000000LL) = 1000000000
myMax(true, false) = 1