Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- class box {
- private:
- double length;
- double breadth;
- double height;
- public:
- void setlength(double);
- void setbreadth(double);
- void setheight(double);
- double getlength() const;
- double getbreadth() const;
- double getheight() const;
- };
- void box::setlength(double len)
- {
- length = len;
- };
- void box::setbreadth(double B)
- {
- breadth = B;
- };
- void box::setheight(double H)
- {
- height = H;
- };
- double box::getlength() const
- {
- return length;
- };
- double box::getheight() const
- {
- return height;
- };
- double box::getbreadth() const
- {
- return breadth;
- };
- int main()
- {
- box box1;
- box box2;
- double volume = 0.0;
- box1.setheight(5.0);
- box1.setlength(6.0);
- box1.setbreadth(7.0);
- box2.setheight (10.0);
- box2.setlength (12.0);
- box2.setbreadth (13.0);
- volume = box1.getheight() * box1.getlength() * box1.getbreadth();
- cout << "Volume of Box1 : " << volume <<endl;
- volume = box2.getheight()* box2.getlength() * box2.getbreadth();
- cout << "Volume of Box2 : " << volume <<endl;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement