Advertisement
avr39ripe

PV024maxTemplateProblemDraft

Nov 18th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. //template <typename T>
  4. //T max(T a, T b)
  5. //{
  6. //  return a > b ? a : b;
  7. //}
  8.  
  9. template <typename T1, typename T2>
  10. T1 max(T1 a, T2 b)
  11. {
  12.     return a > b ? a : b;
  13. }
  14.  
  15. //int max(double a, int b)
  16. //{
  17. //  return a > b ? a : b;
  18. //}
  19. //int max(int a, int b)
  20. //{
  21. //  return a > b ? a : b;
  22. //}
  23. //
  24. //double max(double a, double b)
  25. //{
  26. //  return a > b ? a : b;
  27. //}
  28.  
  29. int main()
  30. {
  31.     std::cout << max(3, 4) << '\n';
  32.     std::cout << max(3.5, 4.5) << '\n';
  33.     std::cout << max(3, 3.5) << '\n';
  34.     std::cout << max(3.5, 3) << '\n';
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement