I have a class like
class Date{
public:
Date(int year, int month, int date);
Date(const Date &d);
Date &operator=(const Date &d);
bool isHoliday();
void addDays(int days);
}
In my addDays()
implementation, I need to make a call to isHoliday()
. I have the following two options, both of which seem to be allowed by the compiler.
Option 1:
void Date::addDays(int days) {
if (this->isHoliday()) {
// body
}
}
Option 2:
void Date::addDays(int days) {
if (isHoliday()) {
// body
}
}
Is there any difference between the two definitions? Which is the correct one to use? Thanks.
EDIT: The referenced duplicate question indeed answers my question. Just couldn't find it as I was searching by ->
. I can't delete this now, but do refer to that question for a good number of answers.