class MyString
{
public:
MyString(const TCHAR* str){ buff=0; length=0; operator =(str); }
#ifdef USE_COPY_CONSTRUCTOR
MyString(MyString& copy){ buff=0; length=0; operator = (copy); }
#endif // USE_COPY_CONSTRUCTOR
~MyString(){ if(buff) free(buff); }
MyString& operator = (const TCHAR* str){ if(buff) free(buff); buff=_tcsdup(str); len=_tcslen(buff); return *this; }
operator const TCHAR* () { return buff?buff:__TEXT(""); }
private:
TCHAR* buff;
unsigned int length;
};
{
MyString aaa(__TEXT("aaa"));
MyString bbb = aaa;
}
#define USE_COPY_CONSTRUCTOR
{
MyString aaa(__TEXT("aaa"));
MyString bbb = aaa;
}
by default members are copied by memcopy.