C++ vector 的简单用法
2016-05-11 17:23
477 查看
C++ vector 的简单用法
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
vector SS;
}
#include "stdafx.h" #include<vector> #include <String> #include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
vector SS;
SS.push_back("The number is 10"); SS.push_back("The number is 20"); SS.push_back("The number is 30"); cout << "Loop by index:" << endl; int ii; for (ii = 0; ii < SS.size(); ii++) { cout << SS[ii] << endl; } cout << endl << "Constant Iterator:" << endl; vector<string>::const_iterator cii; for (cii = SS.begin(); cii != SS.end(); cii++) { cout << *cii << endl; } cout << endl << "Reverse Iterator:" << endl; vector<string>::reverse_iterator rii; for (rii = SS.rbegin(); rii != SS.rend(); ++rii) { cout << *rii << endl; } cout << endl << "Sample Output:" << endl; cout << SS.size() << endl; cout << SS[2] << endl; swap(SS[0], SS[2]); cout << SS[2] << endl; return 0;
}
相关文章推荐
- c++第五次实验--多继承
- more effective C++的读书笔记 ——不要重载&&和||
- 【C语言】动态内存分配alloca
- C++之嵌套类与外围类及友元
- C++中的::操作符
- 关于C++全局变量声明的问题
- c++第五次上机实验——教师干部类
- C++实现双链表
- C++实现双链表
- C++实现双链表
- 基于C语言EOF与getchar()的使用详解
- 第7周 C语言程序设计(新2版) 练习1-13 打印输入单词长度的直方图(水平与垂直)
- 栈的测试--四则运算表达式求值(C语言)
- C++程序设计语言练习5.1
- C语言 文件操作12--文件加密
- C++中的vector容器对象学习笔记
- C++ typedef用法小结
- iOSDay09C语言函数指针
- iOSDay08之C语言内存管理
- iOSDay07之C语言指针