I am working thru a C++ text (coming from VB) and the following class is generating an error. I have looked thru three different books and online tutorials and am still confused.
#include <iostream.h>
class Employee
{
public:
int GetAge() const {return itsAge;}
void SetAge(int age) {itsAge = age;}
int GetYearsOfService() const {return YearsOfService;}
void SetYearsOfService(int years) {YearsOfService = years;}
int GetSalary() {return Salary;}
void SetSalary(int salary) {Salary = salary;}
private:
int itsAge;
int YearsOfService;
int Salary;
};
int main()
{
Employee John;
Employee Sally;
John.SetAge(32);
John.SetYearsOfService(5);
John.SetSalary(50000);
Sally.SetAge(32);
Sally.SetYearsOfService(8);
Sally.SetSalary(40000);
cout << "John is " << John.GetAge << " years old.\n";
cout << "He has been with the company for " << John.GetYearsOfService << " years.\n";
cout << "John earns $" << John.GetSalary << " per year.\n\n";
cout << "Sally is " << Sally.GetAge << " years old.\n";
cout << "She has been with the company for " << Sally.GetYearsOfService << " years.\n";
cout << "Sally earns $" << Sally.GetSalary << " per year.\n\n";
return 0;
}
----------------------------------------------------------------------
Error (lines 34 thru 40):
ex6-3.cpp(34) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type '' (or there is no acceptable conversion)
----------------------------------------------------------------------
I've tried for two days to get it to work and I'm going nuts. Thanks for any help at all.
Minh