(Leaving aside the question of should you have them at all.)
I have always preferred to just use function overloading to give you the same name for both getter and s
If your getter is simply rate()
, your compiler would complain that its a redefinition of your other rate
symbol, provided you gave your field a good meaningful name like that. In that case you need to do something silly like name your member _rate
or some other similar approach. I personally hate seeing/typing those underscores, so tend to go with the getRate()
approach.
This is obviously subjective and this just happens to be my personal preference.