So I need to program a code which will display the values of all my objects which currently are "Monday and Tuesday." I am getting two errors under my printDay function.
Error c2275 'DayOFTheWeek': illegal use of this type as an expression
Error c2228: left of '.printDay' must have class/struct/union
I will admit I know I'm not properly programming this part correctly but I have already failed other attempts to fix this.
/*Author:DaniwebOS*/
#include <iostream>
#include <conio.h>
#include <string>
using namespace std;
class DayOfTheWeek
{
private:
string day;
public:
void setDay(string);
void printDay() const;
string getDay() const;
};
void DayOfTheWeek::printDay() const
{
cout << "The value of the" << DayOfTheWeek.getDay << "is " << day << "." << endl;
}
string DayOfTheWeek::getDay() const
{
return day;
}
int main()
{
DayOfTheWeek Monday;
DayOfTheWeek Tuesday;
Monday.setDay("Mon");
Tuesday.setDay("Tues");
string currentDay = Monday.getDay();
currentDay = Tuesday.getDay();
Monday.printDay();
Tuesday.printDay();
getch();
return 0;
}