Hello, All!
i admit that it's better to ask questions connected with atl/mfc classes in
special newsgroups, but seems like people there are interested more in
discussing stuff like MFC GUI than C++ 8-/, so i'll better ask here too..
CStringW is a class in atl/mfc dealing with strings 8-]. the only typecast
operator i found is to PCXSTR that is LPCWSTR that is simply "const unsigned
short*" (wchar_t is unsigned short).
wcout accepts wchar_t* strings. so i expect i can ouptut that CStringW into
wcout using <<, or compiler should generate some error.
but it does funny thing - it prints address of string instead of it - << for
const void * is called. even more funny - if i explicitly cast to the
pointer all is well. i tried different types but no one causes printing
address.
such behaviour could be possible if << is defined for CString and it's
broken, but i found no such definition.
i have no ideas what else can be causing this behaviour.. if anybody have
ideas what's happening or how to investigate it - please help.
here's code causing problems:
CStringW myStr(L"A");
std::wcout<<myStr<<std::endl;
std::wcout<<CStringW::PCXSTR(myStr)<<std::endl;
std::wcout<<(const unsigned short*)(myStr)<<std::endl;
generated output is
00325CF0
A
A
i even tried to debug in disassembly - it appears that in all three cases
cast of CStringW to "unsigned short const *" is called, then in first case
it goes into "const void*" output, in other two - into normal string
output..
With best regards, Alex 'killer_storm' Mizrahi.