How many line types in visual c ++

How many types of string classes exist in Visual C ++. I was confused when going through the center of msdn.

I found this type in 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 definitions of the row header. It didn’t look like the one above. One thing that I noticed is that it goes into STL. (Pls see comment for link, I cannot post two links in the same post)

which is commonly used? I am in a difficult situation with different string classes

Thank you in advance:)

+4
source share
2 answers

Different libraries have different line types:

In normal old C, you use char* , the standard C ++ library provides std::string , which is widely used in C ++ development. (a string is defined as typedef basic_string<char> string; )

Microsoft created the MFC class CString , which (was?) Used in MFC style programming, Qt has a QString that is used in Qt programs. What you mention with System.String is a .net string class that can only be used in managed code (with .net).

I would advise sticking with std::string (#include <string> ) if you are new to C ++. It is standard and platform independent.

+6
source

The types of strings commonly used in Microsoft code are char *, wchar_t *, LPSTR, LPTSTR, LPWSTR, LPCSTR, LPCTSTR, LPCWSTR, BSTR, OLESTR, UNICODE_STRING, String, string, wstring, _bstr_t, CString

The last 5 classes. You choose the one that gives you the least headaches when converting, depending on which API you need to use:

  • std :: string and wstring, C ++ standard library
  • System :: String, the type of string for managed code
  • _bstr_t, a wrapper for BSTR used in COM automation
  • CString, a string type for ATL and MFC libraries.

When working with other APIs, you are likely to come across additional string types.

+3
source

Source: https://habr.com/ru/post/1333186/


All Articles