1// Program to illustrate the working of
2// objects and class in C++ Programming
3
4#include <iostream>
5using namespace std;
6
7// create a class
8class Room {
9
10 public:
11 double length;
12 double breadth;
13 double height;
14
15 double calculateArea() {
16 return length * breadth;
17 }
18
19 double calculateVolume() {
20 return length * breadth * height;
21 }
22};
23
24int main() {
25
26 // create object of Room class
27 Room room1;
28
29 // assign values to data members
30 room1.length = 42.5;
31 room1.breadth = 30.8;
32 room1.height = 19.2;
33
34 // calculate and display the area and volume of the room
35 cout << "Area of Room = " << room1.calculateArea() << endl;
36 cout << "Volume of Room = " << room1.calculateVolume() << endl;
37
38 return 0;
39}