(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
A few years ago, I would have agreed completely. More recently, a doubt began to make its way, because that makes taking the address of a getter or setter ambiguous. With tools like tr1::bind, this is really annoying.
For example:
struct A
{
void Foo(int);
int Foo()const;
};
std::vector v = ....;
std::vector foos;
// Extract Foo
std::transform(
v.begin(), v.end(),
std::back_inserter(foos),
//Ambiguous
// std::tr1::bind(&A::Foo)
//must write this instead. Yuck!
std::tr1::bind(static_cast(&A::Foo));
);
Leaving aside the question of should you have them at all ;-)