fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. template <class T>
  6. auto Max(T a, T b) {
  7. return a > b ? a : b;
  8. };
  9.  
  10. struct box {
  11. double height;
  12. double width;
  13. double length;
  14. double volume;
  15. };
  16.  
  17. void setVolume(box &b) {
  18. b.volume = b.height * b.width * b.length;
  19. }
  20.  
  21. template<>
  22. auto Max<box>(box b1, box b2) { //Ошибка
  23. return b1.volume > b2.volume ? b1.volume : b2.volume;
  24. }
  25.  
  26. int main() {
  27. box b1 = { 5, 4, 2 };
  28. box b2 = { 10, 10, 2 };
  29. setVolume(b1);
  30. setVolume(b2);
  31. cout << Max(b1, b2) << endl;
  32. }
  33.  
Success #stdin #stdout 0s 4344KB
stdin
Standard input is empty
stdout
200