#include <iostream.h>
/********************************************************
File: class1.C
Instantiate a date object, initialize it, and print it
*********************************************************/
class date {
int day;
int month;
int year;
public:
void init(int , int , int );
void print();
};
void date::init(int d, int m, int y)
{
day = d;
month = m;
year = y;
}
void date::print()
{
cout << "The date stored in this object is:" << endl;
cout << "Day: " << day << endl;
cout << "Month: " << month << endl;
cout << "Year: " << year << endl;
}
typedef date Date;
int main()
{
int day, month, year;
Date today;
cout << "Enter today's date in DD MM YYYY format: ";
cin >> day >> month >> year;
today.init(day, month, year);
today.print();
exit(0);
}
Back to Previous Page
Document:
Local Date:
Last Modified On: