#include<iostream.h>
#include<conio.h>
class date
{
int day;
int month;
int year;
public:
friend operator >>(istream &,date &);
friend operator <<(ostream &,date &);

};
operator >>(istream &din,date &d)
{
cout<<"\nEnter Date : ";
cout<<"\n\nEnter day:";
din>>d.day;
cout<<"\nEnter month:";
din>>d.month;
cout<<"\nEnter year:";
din>>d.year;
}
operator<<(ostream &dout,date &d)
{
dout<<d.day<<"/"<<d.month<<"/"<<d.year<<"\n";
}
int main()
{
date d;
clrscr();
cin>>d;
cout<<"\n\nDate is : ";
cout<<d;
getch();
return(0);
}

Post a Comment

Previous Post Next Post