K
Kiarra
The operators << and >> are not available for the atl version of CString, so
assuming I derive a class from CString, say CStringS, how do I add the
operator<< to the class ?
I have tried various methods, some sort of work, for CStrings but go
horribly wrong when used with _T("...") as they are constant chars, and a
temporary object gets created and then variables get lost, or others give
compiler errors of
error C2678: binary '<<' : no operator found which takes a left-hand operand
of type 'CStringS' (or there is no acceptable conversion)
1> \harness\cstrings.h(28): could be 'std:stream &operator
<<(std:stream &,CStringS)' [found using argument-dependent lookup]
even though there is only overloaded operator.
What I need to do is something like:
CStringS h = _T("Hello");
CStringS w = _T("World");
CStringS cs;
cs << h << _T(" Sunny ") << w << std::endl;
cout << cs;
Any ideas ? Ive been trying to get this to work for sometime now but its
really causing me a huge headache and there is nothing on the web.
Thanks
assuming I derive a class from CString, say CStringS, how do I add the
operator<< to the class ?
I have tried various methods, some sort of work, for CStrings but go
horribly wrong when used with _T("...") as they are constant chars, and a
temporary object gets created and then variables get lost, or others give
compiler errors of
error C2678: binary '<<' : no operator found which takes a left-hand operand
of type 'CStringS' (or there is no acceptable conversion)
1> \harness\cstrings.h(28): could be 'std:stream &operator
<<(std:stream &,CStringS)' [found using argument-dependent lookup]
even though there is only overloaded operator.
What I need to do is something like:
CStringS h = _T("Hello");
CStringS w = _T("World");
CStringS cs;
cs << h << _T(" Sunny ") << w << std::endl;
cout << cs;
Any ideas ? Ive been trying to get this to work for sometime now but its
really causing me a huge headache and there is nothing on the web.
Thanks