14/10/16 16:31
Birkhoff92
Salve, sto eseguendo un programmino che ho preso sul Deitel&Deitel , e ho un dubbio : qui , perchè definisce quei giorni come un array di 13 con tutti tra 30 e 31 ? non dovrebbero essere 12 ??
la funzione checkDay è definita qui invece :
int Date:: checkDay(int testDay) const { static const int daysPerMonth[13]= {0,31,28,31,30,31,30,31,31,30,31,30,31}; if (testDay >0 && testDay <= daysPerMonth[month]) return testDay; if(month ==2 && testDay==29 &&(year %400==0 || (year%4==0 && year&100==0))) return testDay; cout<<"Invalid day ("<<testDay<<")set to 1.\n"; return 1; } //fine funzione checkDay
la funzione checkDay è definita qui invece :
#ifndef Date_h #define Date_h class Date { public: Date(int = 1, int=1,int=1900); void print()const; ~Date(); private: int month; int day; int year; int checkDay(int) const; // funzione d'utilità per convalidare mese e anno }; #endif /* Date_h */. Grazie per i chiarimenti
aaa