请教大家一个问题
学习C++,有个题目是编写风扇的类,头文件#include <string>
class Fan
{
public:
Fan();
double getSpeed();
bool isOn();
double getRadius();
string getColor();
void setSpeed(int);
void setOn(bool);
void setRadius(double);
void setColor(string color);
private:
int speed;
bool on;
double radius;
string color;
};
头文件的实现是
#include "Fan.h"
Fan::Fan()
{
speed = 1;
on = false;
radius = 5;
color = string("blue");
}
int Fan::getSpeed()
{
return speed;
}
bool Fan::isOn()
{
return on;
}
double Fan::getRadius()
{
return radius;
}
string Fan::getColor()
{
return color;
}
void Fan::setSpeed(int speed)
{
this ->speed = speed;
}
void Fan::setOn(bool on)
{
this ->on = on;
}
void Fan::setRadius(double radius)
{
this ->radius = radius;
}
void Fan::setColor(string color)
{
this -> color = color;
};
编写了一个小测试主函数,总是编译出错,出错位置是头文件里的这句:string getColor();
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
请教大家这个怎么出错了?谢谢