I have a class name MyDate with the following members and methods:
class MyDate
{
public:
MyDate();
void setDay(int d);
void setMonth(int m);
void setYear(int y);
void set(int day_, int month_, int year_);
void print ();
private:
int day;
int month;
int year;
};
I have another class names Calendar which has an array of pointers to MyDate.
class Calendar
{
public:
Calendar() ;
void setDate (int num);
bool isFree(int num_);
int firstFree();
void insertDate(MyDate my_date_);
void print ();
private:
std::array<MyDate*, 30> m_dates;
};
I implement the insert function in the following way:
void Calendar :: insertDate(MyDate my_date)
{
int f = firstFree()-1 ;//the first free index in the array
*m_dates[f]=my_date; //is there a way to implement it without getters from //MyDate class??
}
I know that I can't do *m_dates[f]=my_date;
--->just to explain what I have to implement.
is there a way to implement it without getters from MyDate class??