Why is there a different string class in every C++ platform out there?(为什么每个 C++ 平台都有不同的字符串类?)
问题描述
虽然我喜欢用 C++ 编程,但我讨厌这样的想法:std::basic_string vs QString vs wxString vs .............standard string 类不能满足这些框架的需求吗?我的意思是 standard string 类有什么问题?!
While I like programming in C++, I hate the idea of:
std::basic_string vs QString vs wxString vs .............
Doesn't the standard string class satisfy the needs for these frameworks? I mean what is wrong with the standard string class?!
只是强调一下,以下是重要的问题:
您是否在要使用的每个框架中都学习了框架的字符串"类?你会改用标准的字符串类,尝试在任何地方进行调整吗?
Just to emphasize, that below is the important question:
Do you learn "the" string class of the framework in every framework you are going to work with? would you instead stick to the standard string class by trying to adapt it everywhere?
谢谢...
推荐答案
之所以有多个字符串类,是因为 C++ 标准的定稿比较晚(1998 年);然后花了一些时间,直到所有系统都真正提供了正确的 C++ 库.到那时,所有这些相互竞争的字符串类都已经编写好了.
The reason for multiple string classes is that the C++ standard was finalized fairly late (in 1998); it then took some time until all systems actually provided a correct C++ library. By that time, all these competing string classes where already written.
此外,在某些情况下,人们希望从单个基类继承,而 std::string 不会这样做.
In addition, in some cases, people want to inherit from a single base class, which std::string wouldn't do.
这篇关于为什么每个 C++ 平台都有不同的字符串类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为什么每个 C++ 平台都有不同的字符串类?
基础教程推荐
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- CString 到 char* 2021-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
