I have created an IString class that wraps around stl string. When I test my classes + operator this is what I get:
output: sEdc =Freddy Flinty''Code:IString sEdc= "Freddy Flinty"; sEdc = "'" + sEdc + "'"; cout<< "sEdc =" << sEdc<<endl;
expected output: sEdc ='Freddy Flinty'
Here is my operator definition
Any ideas on what I am doing wrong?Code://buffer is the stl string private data member defined in the header file IString IString::operator + ( const IString &aString ) const { IString result(buffer, aString); return result; } IString IString::operator + ( const char *pString ) const { IString result(buffer, pString); return result; } IString operator + ( const char *pString, const IString &aString ) { IString result(aString.buffer, pString); return result; } IString::IString(string str, const char* pString) { buffer = str; //buffer is an stl string buffer += pString; }



LinkBack URL
About LinkBacks


