Define a class Data using constructor assign a value and display it
#include<iostream.h>
#include<conio.h>
class date{
int day;
int month;
int year;
public:
date(int d,int m,int y)
{
day=d;
month=m;
year=y;
cout<<day<<"/"<<month<<"/"<<year<<"\n";
}
};
void main()
{
clrscr();
date D(12,10,2007);
getch();
}
Output:
12/10/2007
No comments:
Post a Comment