In More Effective C++, the following codes are given
const String::CharProxy String::operator[] (int index) const
{
return CharProxy(const_cast<String&>(*this), index);
}
String::CharProxy::operator char() const
{
return theString.value->data[charIndex];
}
Why don't we just return a char instead of using const_cast and casting CharProxy to char later?