1.
Below is the
struct definition for Room, which has a length, width, and height. It also has two member functions, calculateArea and calculateVolume. Turn this struct into a class with private member variables.
Solution.
Below is the
class definition of Room. As you can see, there isnβt a big difference between structs and classes.
#include <iostream>
using namespace std;
class Room {
private:
int length;
int width;
int height;
public:
int calculateArea () {
return length * width;
}
int calculateVolume () {
return length * width * height;
}
};
