Hi,
I coded a class for strings and I have a doubt about the + operator.
I'd like to return a temporary variable (I don't want to modify the string
whose + operator is executed)
and I don't want to return a dynamically allocated object because it should
be freed out of the class (using free or delete).
My code right now is as follows and looks like it works but I ain't sure if
it's correct.


class MyString
{
public:

MyString() { Data[0]='\0'; }
MyString(const char* s) { strcpy(Data,s); }
MyString(const MyString& s) { strcpy(Data,s.Data); }

MyString operator+(const MyString &r)
{
char buf[256];
strcpy(buf,Data);
strcat(buf,r.Data);
return MyString(buf);
}

char Data[256];
};