I'm trying to understand the following member function:
void Date::setDays(const std::vector<Date> &days){
Date d(1, 1, 1);
m_days = days;
m_days.push_back(d); // valid.
days.push_back(d); // invalid.
}
In the member function above that belongs to the class Date
, I'm passing days
by reference as a const. I can understand why it is illegal to add an element to days
as it is const
. However, my confusion is, how is it possible that I can add an element to m_days
? Doesn't it refer to the same vector as days
? When I add an element to m_days
, does it mean I'm adding an element to days
too?