Create a class date. Its member data should consist of three ints: month, day, and
year. It should also have two member functions: getdate(), which allows the
user to enter a date in 12/31/02 format, and showdate(), which displays the
date.
SOLUTION:
#include "stdafx.h"
#include "iostream"
using namespace std;
/////////////////////////////////////////////////////////////////////////////////////////
class date
{
private:
int
month,day,year;
public:
void
getdate( )
{
cout << "Enter DAY, MONTH
& YEAR Respectively ";
cin >> day >> month
>> year;
}
void
showdate( ) const
{
cout << "Date is :
"<< day << "/" << month << "/"
<< year << endl;
}
};
/////////////////////////////////////////////////////////////////////////////////////////
void main( )
{
date
date1;
date1.getdate(
);
date1.showdate(
);
system("pause");
}
OUTPUT:
0 comments: