I am programming in C++ for many years, still I have doubt about one thing. In many places in other people code I see something like:
void Classx::memberfunction() { this->doSomething(); }
If I need to import/use that code, I simply remove the this-> part, and I have never seen anything broken or having some side-effects.
void Classx::memberfunction() { doSomething(); }
So, do you know of any reason to use such construct?
EDIT: Please note that I’m talking about member functions here, not variables. I understand it can be used when you want to make a distinction between a member variable and function parameter.
EDIT: apparent duplicate: Are there any reasons not to use "this" ("Self", "Me", …)?
To guarantee you trigger compiler errors if there is a macro that might be defined with the same name as your member function and you’re not certain if it has been reliably undefined.
No kidding, I’m pretty sure I’ve had to do exactly this for that reason!