Create a class heater that contains a single integer field temperature. Define a constructor that takes no parameter. The temperature field should be set to the value 15 in the constructor. Define the mutates warmer and cooler, whose effect is to increase or decrease the value of the temperature by 5.
class Heater {
public:
int temperature;
Heater() {
temperature = 15;
}
void warmer() {
temperature+=5;
}
void cooler() {
temperature-=5;
}
};
Comments
Leave a comment