Given the following date class interface: class date {private: int month;//1 - 1
ID: 3848914 • Letter: G
Question
Given the following date class interface: class date {private: int month;//1 - 12 int day;//1 - 28. 29. 30. 31 depending on month & year int year;//4-digit, e.g.. 2017 public: date();//Default constructor (investigate; find what it is used for)//Postcondition: the newly declared date object is initialized to 01/01/2000 date(int mm, int dd, int yyyy);//Second constructor//Postcondition: the newly declared data object is initialized to mm/dd/yyyy void setDate(int mm. int dd. int yyyy);//Postcondition: set the contents of the calling date object to the values passed to the function void displayDateV1();//Postcondition: display the calling date object in mm/dd/yyyy format, e.g., 02/22/2017 void displayDateV2();//Postcondition: display the calling datecobject in the format like: February 22. 2017 int compareDates(date &dObj;);//compares the two date objects: the calling one the dObj that is passed to the function//Postcondition: returns - 1. 0. or 1 if the calling date object if less than, equal to, or greater than dObj. respectively.}; Your are asked to: Implement all six member functions: Write a main() function containing C++ code to test all six member functions. Note that for the compareDates function, you must test all three possibilities! Format you program output so make it easily readable.Explanation / Answer
#include #include char string1[] = "2012-12-06 14:28:51"; char string2[] = "2011-12-06 14:28:51"; int main( void ) { char tmp[20]; int result; printf( "Compare strings: %s %s ", string1, string2 ); result = strcmp( string1, string2 ); if( result > 0 ) strcpy( tmp, "greater than" ); else if( result < 0 ) strcpy( tmp, "less than" ); else strcpy( tmp, "equal to" ); printf( " strcmp: String 1 is %s string 2 ", tmp ); return 0; }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.