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++ 平台都有不同的字符串类?
- 近似搜索的工作原理 2021-01-01
- 从python回调到c++的选项 2022-11-16
- C++ 协变模板 2021-01-01
- Stroustrup 的 Simple_window.h 2022-01-01
- 如何对自定义类的向量使用std::find()? 2022-11-07
- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01
- STL 中有 dereference_iterator 吗? 2022-01-01
- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01
- 静态初始化顺序失败 2022-01-01
- 使用/clr 时出现 LNK2022 错误 2022-01-01