I'm trying to use a dynamic array in a class but I'm getting "a non static member must be relative to a specific object" error. Here's the code.
class Calendar
{
private:
static int holidayCount;
int * holidayDates = new int[10];
public:
static void addHolidayCount()
{
holidayCount++;
}
static int getHolidayCount()
{
return holidayCount;
}
static void addHolidayDate(int day, int month, int year)
{
holidayDates[0] = 1;
}
};
If I use this same type of setup within my main function I don't get any errors. For example:
int * holidayDates = new int[10];
holidayDates[0] = 1;
I'm guessing I have some kind of syntax error here but I'm not sure what.
holidayDates) in static method (addHolidayDate)