I'm working on this program that runs some functions on a class called dayType, where the user enters a day and then the program can tell you the next day, previous day, etc. The problem I have is that when I try to compile the program, in the implementation file the function printDay() is causing issue. The compiler is saying, "Out of line definition of 'printDay' does not match any declaration in 'dayType'. It seems like everything is set up correctly, but I'm not sure what the issue is. Any help or suggestions are greatly appreciated.
#include "dayType.h"
#include <string>
#include <iostream>
dayType::dayType()
{
days[0] = "Sunday";
days[1] = "Monday";
days[2] = "Tuesday";
days[3] = "Wednesday";
days[4] = "Thursday";
days[5] = "Friday";
days[6] = "Saturday";
currentDay = days[0];
numDays = 0;
}
string dayType::setDay(string newDay)
{
currentDay = newDay;
return newDay;
}
void dayType::printDay()
{
cout << "Day chosen is " << currentDay << endl;
}
int dayType::showDay(int& day)
{
return day;
}
int dayType::nextDay(int day)
{
day = ++day;
if (day > 6)
day = day % 7;
switch (day)
{
case 0: cout << "The next day is Sunday";
break;
case 1: cout << "The next day is Monday";
break;
case 2: cout << "The next day is Tuesday";
break;
case 3: cout << "The next day is Wednesday";
break;
case 4: cout << "The next day is Thursday";
break;
case 5: cout << "The next day is Friday";
break;
case 6: cout << "The next day is Saturday";
break;
}
cout << endl;
return day;
}
int dayType::prevDay(int day)
{
day = --day;
switch (day)
{
case -1: cout << "The previous day is Saturday.";
break;
case 0: cout << "The previous day is Saturday.";
break;
case 1: cout << "The previous day is Saturday.";
break;
case 2: cout << "The previous day is Saturday.";
break;
case 3: cout << "The previous day is Saturday.";
break;
case 4: cout << "The previous day is Saturday.";
break;
case 5: cout << "The previous day is Saturday.";
break;
default: cout << "The previous day is Saturday.";
}
cout << endl;
return day;
}
int dayType::calcDay(int addDays, int numDays)
{
addDays = addDays + numDays;
if (addDays > 6)
addDays = addDays % 7;
switch(addDays)
{
case 0: cout << "The calculated day is Sunday.";
break;
case 1: cout << "The calculated day is Monday.";
break;
case 2: cout << "The calculated day is Tuesday.";
break;
case 3: cout << "The calculated day is Wednesday.";
break;
case 4: cout << "The calculated day is Thursday.";
break;
case 5: cout << "The calculated day is Friday.";
break;
case 6: cout << "The calculated day is Saturday.";
break;
default: cout << "Not valid choice.";
}
cout << endl;
return addDays;
}