Possible Duplicate:
Elegant solution to duplicate, const and non-const, getters?
Say I have a c++ class with a memberfunction which is overloaded for const, like this:
Type* DoSomething();
const Type* DoSomething() const;
If this is a larger, more complex member, how does one prevent having to write the same code twice ? Can't call any non-const functions from the const one. And calling the const version from the non-const one results in a const pointer wich has to be cast to non-const (wich smells a bit imo).