What is the proper use of the self-testing of this
class?
I sometimes use it inside a method to clear that the variable used is a member variable and not one declared inside the method, but on the other hand I wonder if this is the reason for this, since I think you should always code (and comment ) in a way that is self-evident and therefore makes use of this
unnecessary, and another reason against it would be that you are actually creating more code than necessary.
void function() { while(i != this->length)
Another way to use it, I often meet inside the constructors (mainly in Java), since the parameters have the same name as the member variables that must be initialized. Since Primer claims this is bad code, I do not, but on the other hand I see how to use the same name as the -vars member as the names of the parameters from which they are used.
C++ Constructor::Constructor(int size,int value) : this->size(size), this->value(value) {}; Java Constructor(int size,int value) { this->size = size; this->value = value; }
I hope that in fact there is a rule considering both languages ββ(Java / C ++), if I do not return only for C ++, since this is the one who interests me most.
source share