1 String类型
(1) string.size()的返回值类型为string::size_type,而不是int,不要把size的返回值赋给一个int变量,可能溢出;
实际上很多库类型size操作的返回值类型都是size_type类型,这是一种类似unsigned int的类型;
同样在进行索引时索引值也是size_type类型的;
(2) string类型的转换,需要使用字符串流stringstream,例如:
#include <string>
#include <sstream>
void main()
{
string s;
stringstream ss(s);
double d;
s>>d; //string to double
s<<d; //double to string
}
2 Vector类型
(1) vector只是类模板,vector<data_type>才是数据类型;
(2) 只读时可使用const_iterator类型;
(3) 迭代器算术只定义了iter+int, iter-int, iter1-iter2这三种操作,且减法操作的值类型为difference_type类型;