You are viewing a single comment's thread. Return to all comments →
class Box { private: int m_length, m_breadth, m_height; public: Box() { m_length = 0; m_breadth = 0; m_height = 0; } Box(int length, int breadth, int height) { m_length = length; m_breadth = breadth; m_height = height; } Box(Box &box) { m_length = box.getLength(); m_breadth = box.getBreadth(); m_height = box.getHeight(); } int getLength() { return m_length; } int getBreadth() { return m_breadth; } int getHeight() { return m_height; } long long CalculateVolume() { return 1LL * m_length * m_breadth * m_height; } bool operator<(Box &box) { if (m_length < box.getLength()) { return true; } else if (m_breadth < box.getBreadth() && m_length == box.getLength()) { return true; } else if (m_height < box.getHeight() && m_breadth == box.getBreadth() && m_length == box.getLength()) { return true; } return false; } }; ostream &operator<<(ostream &out, Box &box) { return out << box.getLength() << " " << box.getBreadth() << " " << box.getHeight(); };
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 →