Start with the date structure and transform it into a date class. 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.
#include<iostream>
#include<conio.h>
using namespace std;
class date{
private:
int month, day, year;
char c;
public:
void setDate(){
cout << "Enter Date In This Format 31/12/1999" << endl;
cin >> day>>c>>month>>c>>year;
}
void getDate(){
cout << "Date Entered Is" << endl;
cout << day << c << month << c << year << endl;
}
};
int main(){
date d1;
d1.setDate();
d1.getDate();
}
No comments:
Post a Comment