fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template <class T>
  5. void max (T x, T y)
  6. {
  7. string result;
  8. if (x > y)
  9. cout << x << " is bigger than " << y;
  10. else if (x == y)
  11. cout << x << " is equal to " << y;
  12. else
  13. cout << y << " is bigger than " << x;
  14. }
  15.  
  16. int main()
  17. {
  18. double x = 5.6, y = 4.4;
  19. max (x, y);
  20. }
  21.  
Compilation error #stdin compilation error #stdout 0s 4784KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:19:10: error: call of overloaded ‘max(double&, double&)’ is ambiguous
 max (x, y);
          ^
prog.cpp:5:6: note: candidate: ‘void max(T, T) [with T = double]’
 void max (T x, T y)
      ^~~
In file included from /usr/include/c++/8/bits/char_traits.h:39,
                 from /usr/include/c++/8/ios:40,
                 from /usr/include/c++/8/ostream:38,
                 from /usr/include/c++/8/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/8/bits/stl_algobase.h:219:5: note: candidate: ‘constexpr const _Tp& std::max(const _Tp&, const _Tp&) [with _Tp = double]’
     max(const _Tp& __a, const _Tp& __b)
     ^~~
stdout
Standard output is empty