Created
May 22, 2013 15:25
-
-
Save sprintr/5628462 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @author Amin Ullah Khan | |
| * @copyright Amin Ullah Khan 2013 | |
| * @licence MIT, GPL, LGPL | |
| */ | |
| #include <iostream> | |
| using namespace std; | |
| class CBox { | |
| public: | |
| double _width, _height, _breadth; | |
| void setWidth(double width); | |
| void setHeight(double height); | |
| void setBreadth(double breadth); | |
| double getVolumn(); | |
| }; | |
| double CBox::getVolumn() | |
| { | |
| return _width * _height * _breadth; | |
| } | |
| void CBox::setWidth(double width) { | |
| _width = width; | |
| } | |
| void CBox::setHeight(double height) | |
| { | |
| _height = height; | |
| } | |
| void CBox::setBreadth(double breadth) | |
| { | |
| _breadth = breadth; | |
| } | |
| int main() | |
| { | |
| // Create two objects. | |
| CBox box1, box2; | |
| // Set properties of the first object. | |
| box1.setBreadth(10); | |
| box1.setHeight(20); | |
| box1.setWidth(23); | |
| // declare and init and variable called volumn that will store the volumn of the first object. | |
| double volumn = box1.getVolumn(); | |
| // print the value on the screen. | |
| cout << volumn << endl; | |
| // Setting properties for the second object. | |
| box2.setBreadth(20); | |
| box2.setHeight(60); | |
| box2.setWidth(70); | |
| // store the volumn | |
| double volumn2 = box2.getVolumn(); | |
| // print the volumn | |
| cout << volumn2 << endl; | |
| system("pause"); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment