Hi guys,
I'm having some problem with my C++ assignment. Can't get this part down.
class Date
{
private:
static const int daysInMonth[13];
int monthNo, year, day;
string month;
bool validDate, leapYear;
public:
void displayDaysInMonth();
void displayDate();
void enterDate();
void verifyDate();
void displayOptions();
void ahqError()
{cout << "Error! Enter only a-g or q\n";};
void setDay(int);
void setYear(int);
void setMonth(string);
};
const int Date::daysInMonth[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
Background of my assignment: It's a calender/date check program. Thus, I need it to spot a leap year, thus I need to edit the February month to 29 when necessary.
This is the class I defined for my assignment. It works fine until I need to edit the array values. I tried declaring a normal array, however it doesn't work.
Google'ing turned up the solution of using constant/static arrays.
However, I need to edit 1 of the values.
Any solutions to this? Thanks in advance.
Edit: I know it sounds stupid but I just noticed the constant thing hanging around. Came with the codes I google'ed up, now trying without them. But anyone with any ideas for declaring arrays in class is welcome. :D