Saved Bookmarks
| 1. |
Write the definition of a class BOX in C++ with the following description:Private Members -BoxNumber // data member of integer type-Side // data member of float type -Area // data member of float type -ExecArea() // Member function to calculate and assign Area as Side * SidePublic Members -GetBox() // A function to allow user to enter values of// BoxNumber and Side. Also, this // function should call ExecArea() to Calculate Area-ShowBox() // A function to display BoxNumber. Side and Area |
|
Answer» class Box { int BoxNumber; float Side, Area: void ExecArea() { Area = Side*Side; } public: voidGetBox() { cout>BoxNumber; cin>>Side; ExecArea(); } void ShowBox() { { cout<<"BoxNumber: "<<BoxNumber<<end1; cout<<"Side:"<<Side<<end1; cout<<"Area:"<<Area; } }; |
|