fork download
  1. #include <cstring>
  2. #include <iostream>
  3. //using namespace std;
  4.  
  5. template <typename T>
  6. inline T const& max (T const& a, T const& b)
  7. {
  8. return a < b ? b : a;
  9. }
  10.  
  11. // maximum of two C-strings (call-by-value)
  12. inline char const* max (char const* a, char const* b)
  13. {
  14. return strcmp(a,b) < 0 ? b : a;
  15. }
  16.  
  17. // maximum of three values of any type (call-by-reference)
  18. template <typename T>
  19. inline T const& max (T const& a, T const& b, T const& c)
  20. {
  21. return max (max(a,b), c);
  22. }
  23.  
  24. int main(int argc, char* argv[])
  25. {
  26. std::cout << ::max(7, 42, 68) << std::endl;
  27. return 0;
  28. }
  29.  
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
68