First: I know how to write a program, so I do not ask for help in this. However, I am inserting a copy of the problem so that you can see what the assignment implies. My question specifically addresses where you put the variables so as not to make everything global?
Appointment
Create a class named Date that has integer data items to hold the month, day, and year. The class must have a three-parameter default constructor, which allows you to set the date when creating a new Date object. If the user creates the Date object without passing any arguments or if any of the passed values ββis invalid, the default values ββof 1, 1, 2001 (i.e. January 1, 2001) should be used. The class must have member functions to print dates in the following formats:
3/15/10
March 15, 2010
15 March 2010
Questions
1) The teacher instructed us to avoid using magic numbers in our code, so the first question concerns my implementation of the default constructor:
#define DEFAULT_MONTH 1
#define DEFAULT_DAY 1
#define DEFAULT_YEAR 2001
Date(int month = DEFAULT_MONTH, int day = DEFAULT_DAY, int year = DEFAULT_YEAR);
Is it correct?
2) string, , , . enum ( switch).
const enum MONTH_IDS { JANUARY = 1, FEBRUARY, MARCH, APRIL, MAY, JUNE, JULY,
AUGUST, SEPTEMBER, OCTOBER, NOVEMBER, DECEMBER };
const string MONTH_NAMES[NUM_MONTHS] = { "January", "February", "March",
"April", "May", "June", "July", "August", "September", "October",
"November", "December" };
, ?
, ...
, . , .
!
, , .