#include <iostream>
using namespace std;
class DateType
{
friend bool operator==(DateType&, DateType&);
private:
int day;
int month;
int year;
public:
void setMembers(int d,int m,int y);
void printDate(){cout<<"The Date By Default Is: "<<day<<" / "<<month<<" / "<<year<<endl;};
DateType(int d=1,int m=1,int y=1900);
bool operator<(DateType&);
};
DateType::DateType(int d,int m,int y)
{
day=d;
month=m;
year=y;
}
void DateType::setMembers(int d,int m,int y)
{
day=d;
month=m;
year=y;
}
bool DateType::operator<(DateType&D)
{
if(year<D.year)
return true;
else if(year==D.year && month<D.month)
return true;
else if(year==D.year && month==D.month && day<D.day)
return true;
else return false;
}
bool operator==(DateType&D3 , DateType&D4)
{
if(D3.day==D4.day && D3.month==D4.month && D3.year==D4.year)
return true;
else return false;
}
int main()
{
DateType D1,D2,D3,D4;
int d;
int m;
int y;
D1.printDate();
cout<<"Enter The Day Date For operator < :";
cin>>d;
while(d<1 || d>31)
{
cout<<"Please Enter a proper day date again btw 1-31 For operator < : ";
cin>>d;
}
cout<<"Enter The month Date For operator < :";
cin>>m;
while(m<1 || m>31)
{
cout<<"Please Enter a proper month date again btw 1-31 For operator < : ";
cin>>m;
}
cout<<"Enter The year Date For operator < :";
cin>>y;
while(y<1900 || y>2020)
{
cout<<"Please Enter a proper year date again btw 1900-2020 For operator < : ";
cin>>y;
}
D2.setMembers(d,m,y);
cout<<endl;
if(D2<D1)
{
D2.printDate();
}
else cout<<"The Date are not Equal!!"<<endl;
cout<<"Enter The Day Date For operator == :";
cin>>d;
while(d<1 || d>31)
{
cout<<"Please Enter a proper day date again For operator == : ";
cin>>d;
}
cout<<"Enter The month Date For operator == :";
cin>>m;
while(m<1 || m>31)
{
cout<<"Please Enter a proper month date again For operator == : ";
cin>>m;
}
cout<<"Enter The year Date For operator == :";
cin>>y;
while(y<1900 || y>2020)
{
cout<<"Please Enter a proper year date again For operator == : ";
cin>>y;
}
D3.setMembers(d,m,y);
cout<<endl;
cout<<"Enter The Day Date For operator == :";
cin>>d;
while(d<1 || d>31)
{
cout<<"Please Enter a proper day date again For operator == : ";
cin>>d;
}
cout<<"Enter The month Date For operator == :";
cin>>m;
while(m<1 || m>31)
{
cout<<"Please Enter a proper month date again For operator == : ";
cin>>m;
}
cout<<"Enter The year Date For operator == :";
cin>>y;
while(y<1900 || y>2020)
{
cout<<"Please Enter a proper year date again For operator == : ";
cin>>y;
}
D4.setMembers(d,m,y);
cout<<endl;
if(D3==D4)
{
cout<<"Equal"<<endl;
}
else cout<<"Not Equal"<<endl;
return 0;
}