I need help with exceptions , i want to make Exception for each cout
, i have this method, and i got a little confused about how to make the exception with the try catch for every if
istream & operator>>(istream & input, Date &date)
{
int day, mounth, year;
cout << "please enter day , mounth year" << endl;
input >> day >> mounth >> year;
date.setDay(day);
date.setMonth(mounth);
date.setYear(year);
if (day < 1 || day >31)
throw "Illegal day for month should be number day - between 1 to 31" ;
if (mounth < 1 || mounth > 12)
throw "Illegal month should be number mount - between 1 to 12" ;
if ((mounth == 4 || mounth == 6 || mounth == 9 || mounth == 11)
&& (date.day > 30))
throw "Illegal day for month " ;
if (year == 1 && mounth == 1 && day == 1)
throw "please stop the while loop your date is 1/1/1" ;
return input;
}