calling member functions from within another member function of the same class in C++, objective C
Nawaz is correct: 'this' is implicit. The one exception is if foo were a static function, because in static functions there is no 'this'. In that case, you can't use bar() unless bar() is also a static function, and you can't use this->bar() at all.
bar();//is this possible? or should you say this->bar()
this
is implicit. So both of them are equivalent. You can use any of them. But then I think, if just bar()
is enough, then why use this->bar()
?
Use this
only when there is some ambiguity, otherwise use the simpler one!