Setters with and without this pointer.
-
When QtCreator creates setters for class properties, it uses the attribute directly, ie.
void Models::ZipCode::setZipcode(const QString &value) { zipcode = value; }
But I'm used to always using the
this
pointer:void Models::ZipCode::setZipcode(const QString &value) { this->zipcode = value; }
Are there any differences between these approaches or are they equivalent?
-
@Exotic_Devel they are equivalent , as long as the member variable and the argument do not share the exact same name.
But why would you insist on always writing
this->
this isn't Python ! -
@J-Hilk said in Setters with and without this pointer.:
But why would you insist on always writing this-> this isn't Python !
Habit I acquired when I started using Java. :)
-
@Exotic_Devel said in Setters with and without this pointer.:
@J-Hilk said in Setters with and without this pointer.:
But why would you insist on always writing this-> this isn't Python !
Habit I acquired when I started using Java. :)
Ah, my condolences!
š