There's a class below
class A
{
public:
string& getStr()
{
// Do a lot of work to get str
return str
}
const string& getStr() const;
};
Can I call the first function within the second function? I want to do this, because the second function have a lot of code in common with the first one. It cannot be like this:
const string& A::getStr() const
{
// Wrong
A temp;
return temp.getStr();
}
because there is added a new temp and the inner status between *this and temp is different (*this != temp).
Can it be called like I described?