我想在静态函数中调用数组的字段,dayInMonths()
但编译器告诉我“成员使用无效Date::m_months
的无效使用”。我不知道:(我做错了什么。
。H
class Date
{
public:
..
Months* m_months;
..
public:
Date(..,unsigned int months=0,..);
~Date();
public:
static Days daysInMonth(unsigned int days);
};
class Months
{
public:
unsigned int m_months;
unsigned int m_monthsArray[13];
public:
Months(unsigned int months = 0);
..
日期.cpp
Date::Date(unsigned int days, unsigned int months, unsigned int years)
{
..
m_months->m_months = months;
..
}
Days Date::daysInMonth(unsigned int days=0){
return m_months.m_monthsArray[days];
}
月.cpp
Months::Months(unsigned int months)
{
m_months = months;
m_monthsArray[0] = 29;
m_monthsArray[1] = 31;
...