Output of a class function problem.

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?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include <iostream>
#include <string>

using namespace 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!!!

	}
}
remove line 90 dayType day = day;;
and use cout << day; on line 93
Last edited on
That worked :] thank you for your help.
Topic archived. No new replies allowed.