hello
i have given a program which uses the class. It reads the date of birth. And do all the necessary checks on the given value. e.g. What is the limit of that particular month, whether it is a leap year or not. I am writting the first program using classes. I am having problemin my switch statements which i used for checks the more I try to solve the more I get confused. Need your help. Please check my program. I know it is having many other mistakes also.
#include<iostream.h>
#include<conio.h>
class date
{
public:
date();
void setdate(int, char, int);
void printdate();
private:
int day;
char month[50];
int year;
};
date::date()
{
day=1;
month= 'January';
year= 1990;
}
void date::setdate(int d, char m[50], int y)
{
day = d;
month =m;
year = (y>= 1900 && y<= 3000)? y : 1900;
switch (m)
{
case 1: 'January'
d>=1&&d<=31;
break;
case 2: 'Febrary'
{
if (y%4==0)
d>=1&&d<=29;
else
d>=1&&d<=28;
}
break;
case 3: 'March'
d>=1&&d<=31;
break;
case 4: 'Apirl'
d>=1&&d<=30;
break;
case 5: 'May'
d>=1&&d<=31;
break;
case 6: 'June'
d>=1&&d<=30;
break;
case 7: 'July'
d>=1&&d<=31;
break;
case 8: 'August'
d>=1&&d<=31;
break;
case 9: 'September'
d>=1&&d<=30;
break;
case 10: 'October'
d>=1&&d<=31;
break;
case 11: 'November'
d>=1&&d<=30;
break;
case 12: 'December'
d>=1&&d<=31;
break;
}
}
void date::printdate()
{
cout<<day<<" "<<month<<" "<<year<<endl;
}
void main()
{
date da;
da.setdate(20,Febrary,1990)
cout<<"The date of birth is : ";
da.printdate;
getch();
}