首页 > 编程语言 > 详细

在C++11编译环境中,简单自测了一下C++标准库中的string/vector和迭代器,记录一下

时间:2017-12-09 18:51:44      阅读:241      评论:0      收藏:0      [点我收藏+]
#include <iostream>
#include <vector>
using namespace std;
int main()
{   
    //////////////////// string  测试
    string s = "hello World.";   
    // string s("Hello World.");   //这样写也可以的
    
    cout<< s << std::endl;
   
    //////////////////// vector容器  测试
    vector<int> iVec;
    int i;
    
    for(i = 0; i < 10; i++)
    {
        iVec.push_back(i);
    }

    //////////////////// 迭代器  测试
    auto b = s.begin();     //C++11的简易写法
    auto e = s.end() ;
    
    vector<int>::iterator it;   //以前的写法,应该没人喜欢了吧
    
    for( ; b != e; ++b)
    {
        *b = toupper(*b);
    }
    
    cout << s << endl;
    
   
    return 0;
}

 

在C++11编译环境中,简单自测了一下C++标准库中的string/vector和迭代器,记录一下

原文:http://www.cnblogs.com/joyer/p/8012170.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!