193030

Template max emaple

Jul 21st, 2021 (edited)
446
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.26 KB | None
  1. // Example program
  2. #include <iostream>
  3. #include <string>
  4. using namespace std;
  5. template <class T>
  6. T Max( T const &t1, T const &t2)
  7. {
  8.     return t1 > t2 ? t1 : t2;
  9. }
  10.  
  11. int main()
  12. {
  13.     cout << Max(15,20) << endl;
  14.     cout << Max<double>(2.0,20) << endl;
  15. }
  16.  
RAW Paste Data Copied