I am taking an intermediate programming class, after a somewhat long hiatus. One of the first projects is a somewhat simple assignment that takes a date from the user, and checks to see if it is valid, using classes. I have been working on it for a while, and i seem to be making no progress lately. My current problem is that as soon as i start the program, the program halts, saying that "variable month1 is being used without being defined". I cannot figure out what my problem is, but i suspect that it is something simple. I understand how to create the program, i just get tripped up on the syntax and the implementation of it. Any help is appreciated
Program, the commented out portions are things i am having trouble with, and that i have removed for testing purposes
//a C++ program that accepts a day and month from the user (2005 as the year), checks that they are valid,
//displays the date entered in MM/DD/CCYY format and displays the date
#include "stdafx.h"
using namespace std;
class dateReport
{
private:
int day;
int month;
int year;
public:
dateReport(); // constructor
bool CheckDate(int day1, int month1);
};
bool CheckDate( int day1, int month1)
{
int day1, month1 = 0;
if (month1 > 12 || month1 < 1)
{
cout << "Enter A Valid Month" << endl;
return false;
}
// Supposed to check whether or not the day entered is valid.
//Commented out due to it causing errors
if (month1 == 1 || month1 == 3 || month1 == 5 || month1 ==7 || month1 == 8 || month1 ==10 || month1 ==12 && day1 > 31
|| day1 < 1)
{
cout << "Enter A Valid day" << endl;
return false;
}
/*else if (month1 == 4 month1 == 6 || month1 == 9 || month1 == 11 && day1 < 1 || day1 > 30)
{
cout << "Enter A Valid Day" << endl;
return false;
}*/
else
{
return true;
}
}
// MAIN
int _tmain(int argc, _TCHAR* argv[])
{
int day1, month1;
CheckDate(day1, month1);
while(CheckDate(day1, month1)) // loops until valid input is detected
{
cout << "Enter A Day" << endl;
cin >> day1;
cout << "Enter A Month" << endl;
cin >> month1;
return 0;
}