Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how many types of strings in visual c++

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 :)

like image 896
jaykumarark Avatar asked Jan 21 '23 20:01

jaykumarark


1 Answers

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.

like image 94
Philipp Avatar answered Jan 29 '23 23:01

Philipp