I want to extend the C++ string class, returning subclass references (instead of parent string reference), but this code excerpt...
#include <string>
using namespace std;
class mystring : public string
{
public:
mystring& left( int cnt )
{ return (mystring&)mystring( substr(0,cnt) );
}
};
produces this VS8 compiler error:
error C2440: '' : cannot convert from 'std::basic_string<_Elem,_Traits,_Ax>' to 'mystring'
What's the right way to declare mystring::left() so the compiler will stop complaining, hopefully also eliminating the cast?