Is it possible (or practical) to use strings to hold data types other than text strings and characters?
Is it possible (or practical) to use strings to hold data types other than text strings and characters?
A string holding text strings is definitely not useful.
A basic_string of wchar_t is very useful and even has its own typedef wstring (just as string is a typedef for a basic_string of char).
If you want other types, which is certainly possible and can be useful for some character encodings, you need to specialize the char_traits template on this type.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
You mean like std::vector<unsigned char> ?
That should be able to store any kind of bytes from 0x00 to 0xFF.
It's possible, but not practical.
int, char, BOOL, HANDLE, are all just different size byte groups; For example, char[4] can hold the exact same data as int.