When to use the `this->` pointer in our classes

is it not clearer to use the this pointer when referencing variables of the class instance

void FBullCowGame::Reset() {

	constexpr int32 MAX_TRIES = 8;
	this->MyMaxTries = MAX_TRIES;
....
}

than

void FBullCowGame::Reset() {

	constexpr int32 MAX_TRIES = 8;
	MyMaxTries = MAX_TRIES;
 ....
}

The former make you know exactly where it is coming from, is there any reason why we dont use this->

1 Like

Hello @Tawanda_Minya and dear Community,

I always use the “this->” identifier because it is more clear from where the variable or object is originated.

Cheers
Kevin

Privacy & Terms