class NumDays
{
private:
double hours;
double days;
public:
//constructor that assigns values to both hours and days, but only
//takes in the number of hours as its argument
NumDays(double h = 0)
{ setHours(h);
setDays(h / 8.0);}
// set function that assigns values to both hours and days, but only
//takes in the number of hours as its argument
void setHours(double h)
{ hours = h;
days = h / 8.0; }
double getHours() const
{ return hours; }
// set function that assigns values to both hours and days, but only
//takes in the number of days as its argument
void setDays(double d)
{ days = d;
hours = d * 8.0; }
double getDays() const
{ return days; }
NumDays operator + (NumDays &);
NumDays operator ++ (); // Prefix ++
NumDays operator ++ (int); // Postfix ++
};
int main()
{
NumDays dayOne(17), dayTwo(27), dayThree, dayFour, dayFive;
cout << "Day One: " << dayOne.getDays() << endl;
cout << "Day Two: " << dayTwo.getDays() << endl;
// Overloaded Add
dayThree = dayOne + dayTwo;
// Display Day three.
cout << "Day Three (in days): " << dayThree.getDays() << endl;
cout << "Day Three (in hours): " << dayThree.getHours() << endl;
cout << endl;
// Overloaded Postfix increment
dayFour = dayThree++;
cout << "Day Three (in days): " << dayThree.getDays() << endl;
cout << "Day Three (in hours): " << dayThree.getHours() << endl;
cout << "Day Four (in days): " << dayFour.getDays() << endl;
cout << "Day Four (in hours): " << dayFour.getHours() << endl;
cout << endl;
// Overloaded Prefix increment
dayFive = ++dayThree;
cout << "Day Three (in days): " << dayThree.getDays() << endl;
cout << "Day Three (in hours): " << dayThree.getHours() << endl;
cout << "Day Five (in days): " << dayFive.getDays() << endl;
cout << "Day Five (in hours): " << dayFive.getHours() << endl;
system("pause");
return 0;
}
With the above code I am getting the following errors;
: error LNK2019: unresolved external symbol "public: class NumDays __thiscall NumDays::operator++(void)" (??ENumDays@@QAE?AV0@XZ) referenced in function _main
: error LNK2019: unresolved external symbol "public: class NumDays __thiscall NumDays::operator++(int)" (??ENumDays@@QAE?AV0@H@Z) referenced in function _main
: error LNK2019: unresolved external symbol "public: class NumDays __thiscall NumDays::operator+(class NumDays &)" (??HNumDays@@QAE?AV0@AAV0@@Z) referenced in function _main
I'd assume that fixing one error will fix the rest of them, but I've been at this for a while now and cannot figure out what is wrong. Any help is greatly appriciated.