Issue with control mechanism between functions

Below are two functions, the first function, Show, is used to display dates. The following function is used to control the format with which they are displayed. My issues is that Show comes along in the main program before Setformat, so I need a way for the program to know to use the default format(being 3) unless otherwise noted. Can anyone spare some advice?

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
void Date::Show()//Prints date based on format
{
	switch(format)
	{
	case 1: cout << TWODIGIT[month] << '/' << TWODIGIT[day] << '/' << (year%100) << endl;//Prints out Two-Digit date
		break; 
	case 2: cout << MONTH[month]<< day << ',' << year << endl;//Prints out Long date
		break;
	case 3: cout << month << '/' << day << '/' << year << endl;//Prints out Default Date format
		break;
	}

}
bool Date::SetFormat(char f)// Asks user what format they want, stores value in memory
{
	bool formatSucess = true;

	switch(toupper(f)) 
	{
	case 'T': format = 1; 
		break;
	case 'L': format = 2;
		break;
	case 'D': format = 3;
		break;
	default : cout << "You picked something wrong, so we're just gonna set to default. *pats on head*";
		format = 3;
		formatSucess = false;//User entered input incorrectly, thus the function returns false.
	}
	
	return formatSucess;
}


Try setting format to the default value inside the Date constructor.
Zhuge, Thank you. I had no idea one could do something like that!
Topic archived. No new replies allowed.