CString
is not derived from
CObject
so you cannot cast its pointer to
CObject*
.
CString* p_str = new CString(L"Hello");
CObject* p_obj = p_str;
I got this error from VC++ 2019:
error C2440: 'initializing': cannot convert from 'CString *' to 'CObject *'
Highly probable,
CString
used to inherit from
CObject
in older VC++ but not now.