Original Post
OK, so this has been irritating me for a while, and I'm hoping there's some simple workaround that I'm missing. Let's say I have this code: Now, let's say that GetMember contains a substantial amount of code, and both versions do exactly the same thing. I'd like to have one of them just call the other, but I can't have a const member call a non-const member, and I can't have the non-const version return a const reference! How can I do what I'm looking for here without duplicating the code?
class MyClass
{
public:
Member const& GetMember() const;
Member & GetMember();
private:
Member myMember;
}