stl string problems with the + operator
I have created an IString class that wraps around stl string. When I test my classes + operator this is what I get:
Code:
IString sEdc= "Freddy Flinty";
sEdc = "'" + sEdc + "'";
cout<< "sEdc =" << sEdc<<endl;
output: sEdc =Freddy Flinty''
expected output: sEdc ='Freddy Flinty'
Here is my operator definition
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;
}
Any ideas on what I am doing wrong?