#include <iostream>
using namespace std;
// create a class
class Room {
public:
double length;//data members
double breadth;//access data members:- room1.length = 5.5;
double height;
double calculateArea() {//member functions
return length * breadth;//access member functions:- room2.calculateArea();
}
double calculateVolume() {
return length * breadth * height;
}
};
int main() {
// create object of Room class
Room room1;
// assign values to data members
room1.length = 42.5;
room1.breadth = 30.8;
room1.height = 19.2;
// calculate and display the area and volume of the room
cout << "Area of Room = " << room1.calculateArea() << endl;
cout << "Volume of Room = " << room1.calculateVolume() << endl;
return 0;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: