Wednesday, 27 April 2016

Simple Example For Class

#include<iostream.h>
#include<conio.h>
class calender
{
private:
int day,month,year;
public:
void accept()
{
cout<<"Enter the day,month,year:";
cin>>day>>month>>year;
}
void display()
{
cout<<day<<"/"<<month<<"/"<<year;
}
};
void main()
{
calender c;
clrscr();
c.accept();
c.display();
getch();
}

/*OUTPUT:
Enter the day,month,year:2 4 2016
2/4/2016*/

No comments:

Post a Comment