Friday, 22 June 2012

create a c++ class date which contain:

/* create a c++ class date which contain:
-date
-month
-year
write necessary member function to accept and display a data using
<< and >> operator*/
#include<iostream.h>
#include<conio.h>
class date
{
int d,m,y;
public:void accept()
       {
       cout<<"\nenter date:-";
       cin>>d;
       cout<<"\nenter month:-";
       cin>>m;
       cout<<"\nenter year:-";
       cin>>y;
       }
       void display()
       {
       cout<<"\n\ndate:="<<d<<"-"<<m<<"-"<<y;
       }
};
int main()
{
date d;
clrscr();
d.accept();
d.display();
getch();
return 0;
}
/*

enter date:-3

enter month:-4

enter year:-2004


date:=3-4-2004
*/

No comments: