any help would b greatly appreciated for the following
how do i modify this to output the date in multiple formats:
a)DDD YYYY
MM/DD/YY
June 14, 1992
b) use overloaded constructors to create Date objects initialized with dates of the formats in part (a).
c) create a date constructor that reads the system date using the standard library functions of the <ctime> header and sets the Date members

#ifndef DATE_H
#define DATE_H
  class Date
  {
  public:
     Date( int = 1, int = 1, int = 1900 ); // default constructor
     void print() const; // print date in month/day/year format
     ~Date(); // provided to confirm destruction order
  private:
     int month; // 1-12 (January-December)
     int day; // 1-31 based on month
     int year; // any year

     // utility function to check if day is proper for month and year
    int checkDay( int ) const;
}; // end class Date

#endif

Here is a freebee for ye':

c) create a date constructor that reads the system date using the standard library functions of the <ctime> header and sets the Date members

class Date
{
     public:

     //Default constructor
     Date();

     private:

     //Date members
     struct tm* timeinfo;
     time_t rawtime;
     int day;
     int month;
     int year;    
};
Date::Date()
{
     time(&rawtime);
     timeinfo = localtime(&rawtime);

     day = timeinfo->tm_mday;
     month =  timeinfo->tm_mon;
     year =  timeinfo->tm_year + 1900;
}

http://www.cplusplus.com/reference/clibrary/ctime/

Edited 6 Years Ago by Clinton Portis: n/a

Here is a freebee for ye':

class Date
{
     public:

     //Default constructor
     Date();

     private:

     //Date members
     struct tm* timeinfo;
     time_t rawtime;
     int day;
     int month;
     int year;    
};
Date::Date()
{
     time(&rawtime);
     timeinfo = localtime(&rawtime);

     day = timeinfo->tm_mday;
     month =  timeinfo->tm_mon;
     year =  timeinfo->tm_year + 1900;
}

http://www.cplusplus.com/reference/clibrary/ctime/

thanks. i appreciate the help

This article has been dead for over six months. Start a new discussion instead.