fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class cuboid
  5. {
  6. int w,h,l;
  7. public:
  8. cuboid () : w(2), h(3), l(6) {}
  9. cuboid& operator - () { w += 1; return *this; }
  10. cuboid& operator - (cuboid&) { w += 1; return *this; }
  11. cuboid& operator -- (int a) { w += 2; return *this; }
  12. cuboid& operator -- () { w += 2; return *this; }
  13. cuboid& operator ! () { h += 1; return *this; }
  14. cuboid& operator + () { l += 1; return *this; }
  15. cuboid& operator + (cuboid&) { l += 1; return *this; }
  16. cuboid& operator ++ () { l += 2; return *this; }
  17. cuboid& operator ++ (int a) { l += 2; return *this; }
  18.  
  19. void clear () { w = 2; h = 3; l = 6; }
  20. int width () const { return w / 3; }
  21. int height () const { return h / 3; }
  22. int length () const { return l / 3; }
  23. int volume () const { return width() * height () * length (); }
  24. int surface_area() const { return width() * height () * 2 +
  25. width() * length () * 2 +
  26. length() * height () * 2; }
  27. };
  28.  
  29.  
  30. int main() {
  31.  
  32. cuboid b;
  33. b = ( ---------
  34. + +!
  35. ! -------! !
  36. ! ! !
  37. ! ! !
  38. ! !+
  39. ---------b );
  40.  
  41. std::cout << "Width: " << b.width() << std::endl;
  42. std::cout << "Height: " << b.height() << std::endl;
  43. std::cout << "Length: " << b.length() << std::endl;
  44. std::cout << "Volume: " << b.volume() << std::endl;
  45.  
  46.  
  47. return 0;
  48.  
  49. }
Success #stdin #stdout 0s 2884KB
stdin
Standard input is empty
stdout
Width: 9
Height: 5
Length: 3
Volume: 135