This is the first time I have worked with classes and I am stuck. On the last line of code I am trying to output the day via cout << . I am having an issue with using cout << dayType.day; I have also tried cout << day;. I guess my question is, what variable do I use to output the day?
#include <iostream>
#include <string>
usingnamespace std;
//=============== class definition =======================
class dayType
{
private:
string day;
public:
void setDay();
void setDays(string);
void printDay(string);
void returnDay(string);
void returnNextDay(string);
void returnPrevDay(string);
};
int main ()
{
dayType BriansDay;
char answer;
cout << "would you like to set the day?" << endl;
cout <<"type Y for yes or N for no: " << endl;
cin >>answer;
if (toupper(answer) == 'Y')
BriansDay.setDay();
else
cout <<" Fine, be that way" << endl;
system("PAUSE");
return(0);
}
//======================= dayType functions ====================================
void dayType::setDay()
{
char dayName[10];
cout << "Enter the day you would like to set: ";
while (cin)
{
for (int index = 0; index < 10; index++)
{
cin >> dayName[index];
}
}
switch (dayName[0])
{
case'S':
case's':
if (dayName[1]== 'u' || dayName[1] == 'U')
day = "Sunday";
else
day = "Saturday";
break;
case'T':
case't':
if (dayName[1]== 'u' || dayName[1] == 'U')
day = "Tuesday";
else
day = "Thursday";
break;
case'M':
case'm':
day = "Monday";
break;
case'W':
case'w':
day = "Wedensday";
break;
case'F':
case'f':
day = "Friday";
break;
dayType day = day;
cout <<endl;
cout << "/n The day has been set to " ;
cout << dayType.day; //<------------------------------PROBLEM HERE!!!
}
}