iv有一个任务是编写一个加热器程序,该程序会升高和降低温度,这是代码
#include<iostream>
using namespace std;
class heater {
int temperature;
int warmer;
int cooler;
heater()
{
temperature = 15;
warmer = 0, cooler = 0;
}
void setW(int warmer)
{
temperature += 5;
warmer = temperature;
}
void setC(int cooler)
{
temperature -= 5;
cooler = temperature;
}
int getW()
{
return warmer;
}
int getC()
{
return cooler;
}
void show() {
cout << warmer<<endl;
cout << cooler;
}
};
int main()
{
heater hot();
hot.show();
return 0;
}
但是它显示了main函数中的错误,该错误说“表达式必须具有类类型”,我不理解。帮助plz