-
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 语句也有作用域