though I guess some background is in order it's an assignment that has myself creating a class called DayOfTheWeek with three public functions setDay(), getDay() and printDay() now the output needed is the first day inputted and the next day after the first day. the assignment didn't say how to pull this off so I went with a user input method as shown below my first question deals with the errors I mentioned in lines 53, 58, and 69. The second question is such how should I word the if statement
#include <iostream>
#include <string>
using namespace std;
class DayOfTheWeek
{
public:
void setDay(int);
void printDay() const;
void getDay(int&);
private:
string Sun;
string Mon;
string Tues;
string Wed;
string Thurs;
string Fri;
string Sat;
};
void DayOfTheWeek::setDay(int day)
{
if(day=1)
Sun=day;
else if(day=2)
Mon=day;
else if(day=3)
Tues=day;
else if(day=4)
Wed=day;
else if(day=5)
Thurs=day;
else if(day=6)
Fri=day;
else if(day=7)
Sat=day;
}
void DayOfTheWeek::getDay(int day)
{
return day;
}
void DayOfTheWeek::printDay()
{
cout << day;
}
int main()
{
DayOfTheWeek firstDay;
DayOfTheWeek secondDay;
int Day = 0;
Day = firstDay.getDay();
cout << "Welcome to the Set Day Program" << endl;
cout << endl;
cout << "please input what day it is:" << endl;
cout << "1 = Sun" << endl;
cout << "2 = Mon" << endl;
cout << "3 = Tues" << endl;
cout << "4 = Wed" << endl;
cout << "5 = Thurs" << endl;
cout << "6 = Fri" << endl;
cout << "7 = Sat" << endl;
cout << "Make your selection here: ";
cin >> Day;
cout << endl;
cout << "Today is "; firstDay.printDay(); cout << endl;
return 0;
}

New Topic/Question
Reply




MultiQuote






|