-
const std::string::size_type cols = 100;
解析:
-
std::string 是一个类
typedef basic_string<char> string; -
size_type 是一种 basic_string 类定义的类型
class basic_string { ... // Types: public: ... typedef typename _Alloc_traits::size_type size_type; -
size_type 专门用来保存一个字符串的长度,只要是这个用途,就应该用这种数据结构
-
-
普通算术转换规则
-
较小的类型会被转换为较大的类型
-
有符号类型会被转换为无符号类型
-
0值可以视为false,其余视为true
-
-
using namespace-name::name
意思是把 name 作为 namespace-name::name 的替代名
eg. 在前面写 using std::cout, 这样后面直接用 cout 就可以了
注:using 语句也有作用域
chapter2_循环和计算
最新推荐文章于 2025-04-21 00:12:53 发布
本文深入探讨了C++中std::string的size_type类型,解释其如何用于保存字符串长度,并讨论了基本字符串类的基本类型定义及算术转换规则。
1090

被折叠的 条评论
为什么被折叠?



