STL:標準模板類庫
map:集合
vector:矢量(C++中叫做容器)
list:表
迭代器:廣義指針
vector類的運用:
#include <iostream> #include <vector> using namespace std; int main() { vector<int> x;//運用容器類的例子 for(int a=0;a<1000;a++){ x.push_back(a); } vector<int>::iterator p; for(p=x.begin();p<x.end();p++){ cout<<*p<<endl; } return 0; }
List類的運用:
#include <iostream> #include <list> #include <string> using namespace std; int main() { list<string> s; s.push_back("hello"); s.push_back("world"); s.push_front("tide"); s.push_front("crimson"); s.push_front("alabama"); list<string>::iterator p; for(p=s.begin();p!=s.end();p++){ cout<<*p<<endl; } return 0; }
STL(標準模板類庫)簡介
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.