标签:
一、迭代器:迭代器是一种检查容器内元素并遍历元素的数据类型
二、迭代器使用
1 string info = "some thing"; 2 if(info.begin()!= info.end())//判断info对象是否为空 3 { 4 auto t = info.begin();//自定义一个t来接收info对象的第一个元素 5 *t = toupper(*t);//把第一个元素转换成大写 6 } 7 cout<<info<<endl;//Some thing
三、迭代器类型:使用iterator和const_iterator来表示迭代器类型
四、使用cbegin和cend,不论对象是否是常量都会返回const_iterator。
标签:
原文地址:http://www.cnblogs.com/Charles-Wang/p/4617669.html