Why is wchar_t needed? How is it superior to short (or __int16 or whatever)?
(If it matters: I live in Windows world. I don\'t
Why is wchar_t needed? How is it superior to short (or __int16 or whatever)?
In the C++ world, wchar_t is its own type (I think it's a typedef in C), so you can overload functions based on this. For example, this makes it possible to output wide characters and not to output their numerical value. In VC6, where wchar_t was just a typedef for unsigned short, this code
wchar_t wch = L'A'
std::wcout << wch;
would output 65 because
std::ostream::operator<<(unsigned short)
was invoked. In newer VC versions wchar_t is a distinct type, so
std::ostream::operator<<(wchar_t)
is called, and that outputs A.