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
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 使用从字符串中提取的参数调用函数 2022-01-01
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- 从 std::cin 读取密码 2021-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01