Strings in C++

kit / Sun, 13 Aug 2006 22:02:09 GMT

Tags , ,  | 7 comments

Using programming languages such as Ruby and Python (freedom languages?) in order to gain an advantage over over those stuck in the past is sometimes an everyday choice. Here's a list to remind you of why you chose as you did.

  • "I'm so sad"
  • L"I'm so sad"
  • W"I'm so sad"
  • OLESTR("I'm so sad")
  • SysAllocString(L"I'm so sad")
  • _T("I'm so sad")
  • _TEXT("I'm so sad")
  • BSTR
  • CAtlString
  • CAtlStringA
  • CAtlStringW
  • CComBSTR
  • CSimpleStringT
  • CString
  • CStringA
  • CStringT
  • CStringW
  • DBTYPE_BSTR
  • DBTYPE_STR
  • DBTYPE_WSTR
  • LPCSTR
  • LPCTSTR
  • LPCWSTR
  • LPOLESTR
  • LPSTR
  • LPTSTR
  • LPWSTR
  • OLECHAR
  • System::String
  • TCHAR
  • _bstr_t
  • basic_string<char>
  • basic_string<wchar_t>
  • char *
  • std::string
  • std::wstring
  • wchar_t *

These all essentially mean "string" in C++. This list is by no means comprehensive.

Comments / Leave a response

  • phrakture said 42 minutes later:

    Wrong. There is only one string type in C++. That is std::basic_string<...>.

    Your list include std::string and std::wstring which are typedefs of basic_string. All the other string types listed are proprietary and/or left for C support (char*).

    Most of your string types are microsoft specific, and in no way part of C++.

  • yeahbut said about 1 hour later:

    The point is: being stuck in the world of C++ and having to “deal” with the lack of basic data types, like strings, just shows the age of the language. C/C++ will be around for systems programming for a while to come, but modern, dynamically typed languages are fun and simple simple simple.

  • bla@blabla.com said about 1 hour later:

    You do realize that Ruby, Java, Perl, PHP, Pyton etc etc all are written in C/C++ for a reason? I don’t think anyone sane would bootstrap ruby with ruby. Maybe we should hope C stick around for a while longer so simple (as in not smart) developers like yourself have a scripting language to play with in the first place.

  • Scott D. Strader said about 1 hour later:

    No, complaining that you have to “deal” with a chosen framework’s implementations just shows how misguided and uninformed language comparison can be. Phrakture’s right: that list is basically a collection of Microsoft wrappers for either Win32, OLE, COM, or C libraries. If you’re coding in one of those domains, either use the implementations that are given, find a 3rd-party implementation that is more C++ compliant (many elegant libraries exist), or write your own. The option to complain in order to try to start a language war would be better served if there was at least meaningful argument to back it up.

  • name said about 5 hours later:

    wow lets stop the flame war before it starts.. this is pointless.

  • face said 2 days later:

    The many string implementations is a real problem in C++ – think about it from a library perspective. I want to provide you some library that works with strings, but I want to do so as conveniently to you as possible. In order to do, I have to use your matching String implementation. This is simply not possible when you want your library to be used by many different people in many different environments.

    In such a case I chose the lowest common denominator would work best – ye ol’ char* – doesn’t mean I was happy about it.

(leave url/email »)

   Comment Markup Help