that takes a LPCTSTR.
want to use the assignment operator.
On 4 Feb., 18:13, ".rhavin grobert" <cl...@yahoo.de> wrote:
that leads me to the question: can i derive from CString if the only
thing i do is overload the operator=()...
My solution...
//-----------------------------------------------------------------------------
class CQString : public CString
{
public:
// overloaded contructors refer to baseclass
inline CQString() {};
inline CQString(const CString& stringSrc) : CString(stringSrc) {};
inline CQString(LPCTSTR lpsz) : CString(lpsz) {};
#ifdef _UNICODE
inline CQString(LPCSTR lpsz) : CString(lpsz) {};
#else
inline CQString(LPCWSTR lpsz) : CString(lpsz) {};
#endif
// additional constructor for resource-id's
inline CQString(UINT nRscID) {LoadString(nRscID);};
// destructor does nothing
virtual inline ~CQString() {};
// the only real overload, we need to check for ResourceID
const CQString& operator=(LPCTSTR lpsz);
};
//-----------------------------------------------------------------------------
// the only real overload, we need to check for ResourceID
const CQString& CQString::operator=(LPCTSTR lpsz)
{
if (lpsz != NULL && HIWORD(lpsz) == NULL)
{
UINT nID = LOWORD((DWORD)lpsz);
if (!LoadString(nID))
TRACE1("Warning: implicit LoadString(%u) failed\n", nID);
return *this;
}
ASSERT(lpsz == NULL || AfxIsValidString(lpsz));
AssignCopy(SafeStrlen(lpsz), lpsz);
return *this;
}