Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <time.h>
- class Date{
- public:
- Date();
- Date(int);
- ~Date();
- void setDate(int);
- int getDay(){ return day; }
- int getMonth(){ return month; }
- int getYear(){ return year; }
- private:
- int day, month, year;
- };
- //Date.cpp
- Date::Date(){
- time_t now;
- time(&now); // Sets now to current time
- struct tm * timeinfo;
- timeinfo = localtime(&now);
- day = timeinfo->tm_mday;
- month = timeinfo->tm_mon;
- year = timeinfo->tm_year;
- }
- Date::Date(int dt){
- time_t elapsedtime = dt;
- struct tm * timeinfo;
- timeinfo = localtime(& elapsedtime);
- day = timeinfo->tm_mday;
- month = timeinfo->tm_mon;
- year = timeinfo->tm_year;
- }
- Date::~Date(){}
- void Date::setDate(int dt){
- time_t elapsedtime = dt;
- struct tm * timeinfo;
- timeinfo = localtime(& elapsedtime);
- day = timeinfo->tm_mday;
- month = timeinfo->tm_mon;
- year = timeinfo->tm_year;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement