Getter error

I had it as
int32 FBullCowGame::GetHiddenWordLength() const { return MyHiddenWord.length; }

which didn’t work,
but
int32 FBullCowGame::GetHiddenWordLength() const { return MyHiddenWord.length(); }
did. I don’t understand why the ()s are needed? All the other getters don’t have it.

In this case length is method of std::string (it is not a variable) so you have to have parentheses when calling a method.
In other cases when you see no parentheses those are variables.

1 Like

Privacy & Terms