Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- //template <typename T>
- //T max(T a, T b)
- //{
- // return a > b ? a : b;
- //}
- template <typename T1, typename T2>
- auto max(T1 a, T2 b)->decltype(a > b ? a : b)
- {
- return a > b ? a : b;
- }
- //int max(int, int); //std::cout << max(3, 4) << '\n';
- //double max(double, double); //std::cout << max(3.5, 4.5) << '\n';
- //double max(int, double); //std::cout << max(3, 3.5) << '\n';
- //double max(double, int); //std::cout << max(3.5, 3) << '\n';
- //int max(double a, int b)
- //{
- // return a > b ? a : b;
- //}
- //int max(int a, int b)
- //{
- // return a > b ? a : b;
- //}
- //
- //double max(double a, double b)
- //{
- // return a > b ? a : b;
- //}
- int main()
- {
- std::cout << max(3, 4) << '\n';
- std::cout << max(3.5, 4.5) << '\n';
- std::cout << max(3, 3.5) << '\n';
- std::cout << max(3.5, 3) << '\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement