You are viewing a single comment's thread. Return to all comments →
class Box { private: int l = 0, b = 0, h = 0; public: Box() = default; Box(int l, int b, int h) : l(l), b(b), h(h) {} Box(const Box& other) : l(other.l), b(other.b), h(other.h) {} int getLength() { return l; } int getBreadth() { return b; } int getHeight() { return h; } long long CalculateVolume() { return (long)(l * b) * h; } bool operator<(Box& other) { if (this->l < other.l) return true; else if ((this->b < other.b) && (this->l == other.l)) return true; else if ((this->h < other.h) && (this->l == other.l) && (this->b == other.b)) return true; else return false; } friend ostream& operator<<(ostream& oss, Box &box) { oss << box.l << " " << box.b << " " << box.h; return oss; } };
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 →