class X
{
private:
string DATA;
.
.
.
const string read_entry( const string & s ) { return this->(DATA[1]); } //Error
}
What’s wrong with this? I’m trying to access the index of the DATA string, but I get an error when I do this->DATA[1]
The problem appears to be the return type of the function. The stated type is
const stringbut indexing into astringreturns achar. Try the following instead