Advertisement
RobertDeMilo

YB1.10 Указание шаблонного параметра типа

Oct 28th, 2023
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. template <typename T>
  7. T Max(T a, T b)
  8. {
  9.     if (b < a)
  10.     {
  11.         return a;
  12.     }
  13.     return b;
  14. }
  15.  
  16. int main()
  17. {
  18.     //cout << Max(2, 3);
  19.     //cout << Max<double>(2, 3.5) << endl;
  20.     //cout << Max<int>(2, 3.5) << endl;
  21.  
  22.     cout << max<int>(2, 3.5) << endl;
  23.     cout << max<double>(2, 3.5) << endl;
  24.  
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement