How many types of string classes are there in visual c++. I got confused when i was going through the msdn center.
I found this type under the namespace system http://msdn.microsoft.com/en-us/library/system.string(v=VS.71).aspx
and then in the headers section, i found the string header definitions. This seemed different from the above. One thing i noticed, this one comes under the STL. (pls see the comment for the link, i cant post two links in the same post)
which one is normally used? I'm finding a hard time getting around with the different string classes
Thanks in advance :)
Different libraries come with different string types:
In plain old C you would use char*
, the C++ standard library provides std::string
which is widely used in C++ development. (string is defined as typedef basic_string<char> string;
)
Microsoft created the MFC CString
class which is (was?) used in MFC style programming, Qt has its QString
which is used in Qt programs. What you're mentioning with System.String
is a .net string class which can only be used in Managed code (with .net).
I'd suggest to stick with std::string
(#include <string>
) if you're new to C++. It's standard and platform independent.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With