You are viewing a single comment's thread. Return to all comments →
class Box { private: int l, b, h;
public: // Constructors Box() : l(0), b(0), h(0) {} Box(int length, int breadth, int height) : l(length), b(breadth), h(height) {} Box(const Box& other) : l(other.l), b(other.b), h(other.h) {}
// Getters int getLength() const { return l; } int getBreadth() const { return b; } int getHeight() const { return h; } // Volume long long CalculateVolume() const { return 1LL * l * b * h; } // Lexicographic comparison: (l, b, h) bool operator<(const Box& other) const { if (l != other.l) return l < other.l; if (b != other.b) return b < other.b; return h < other.h; } // Output operator friend ostream& operator<<(ostream& out, const Box& B) { out << B.l << " " << B.b << " " << B.h; return out; }
};
Seems like cookies are disabled on this browser, please enable them to open this website
Box It!
You are viewing a single comment's thread. Return to all comments →
class Box { private: int l, b, h;
public: // Constructors Box() : l(0), b(0), h(0) {} Box(int length, int breadth, int height) : l(length), b(breadth), h(height) {} Box(const Box& other) : l(other.l), b(other.b), h(other.h) {}
};