码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2017-12-09 19:35:59      阅读:101      评论:0      收藏:0      [点我收藏+]

标签:return   标准库   tor   编译环境   end   stream   names   col   world   

#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和迭代器,记录一下

标签:return   标准库   tor   编译环境   end   stream   names   col   world   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!