Box It!

  • + 0 comments

    class Box {

    private:
        int l;
        int b;
        int h;
    
    public:
    
    Box() : l(0), b(0), h(0) {}
    Box(int l, int b, int h) : l(l), b(b), h(h) {}
    Box(const Box& B) : l(B.l), b(B.b), h(B.h) {}
    
    int getLength() const {return l;}
    int getBreadth() const {return b;}
    int getHeight() const {return h;}
    long long CalculateVolume() const {
        return static_cast<long long>(l) * b * h;
    }
    
    bool operator<(const Box& B) const {
        if (l < B.l) return true;
        if (l == B.l && b < B.b) return true;
        if (l == B.l && b == B.b && h < B.h) return true;
        return false;
    }
    
    friend ostream& operator<<(ostream& out, Box& B){
        out << B.l << " " << B.b << " " << B.h;
        return out;
    }
    

    };