大家帮我看看这个类的申明和定义为什么会出错
class Employee
{
public:
int Getage() const;
int GetYearsOfService() const;
int GetSalary() const;
void Setage(int age);
void SetYearsOfService(int year);
void SetSalary(int salary);
private:
int itsAge;
int itsYearsOfService;
int itsSalary;
};
//以上类的定义,放在一个.h文件里。
Employee::Getage() const
{
return itsAge;
}
Employee::GetSalary() const
{
return itsSalary;
}
Employee::GetYearsOfService() const
{
return itsYearsOfService;
}
Employee::Setage(int age) //从这里往下好象是错的
{
itsAge = age;
}
……
//以上类的定义,在.cpp文件里
//以下是编译器的出错信息
E:\MyVC\temp\aaa\aaa.cpp(21) : error C2556: 'int __thiscall Employee::Setage(int)' : overloaded function differs only by return type from 'void __thiscall Employee::Setage(int)'
e:\myvc\temp\aaa\nclass.h(7) : see declaration of 'Setage'
E:\MyVC\temp\aaa\aaa.cpp(21) : error C2371: 'Setage' : redefinition; different basic types
e:\myvc\temp\aaa\nclass.h(7) : see declaration of 'Setage'
编译器是Microsoft VC++6.0