STL vector存放資料型別

2021-09-29 17:17:48 字數 971 閱讀 5313

1.vector存放內建資料型別

容器:vector

演算法:for_each

迭代器:vector::iterator

標頭檔案:#include

#include

"pch.h"

#include

#include

#include

using

namespace std;

void

myprint

(int val)

void

test01()

//第二種遍歷

for(vector<

int>

::iterator it = v.

begin()

; it != v.

end(

); it++

)//第三種遍歷,利用stl提供的遍歷演算法

for_each

(v.begin()

,v.end()

,myprint);}

intmain()

2.存放自定義資料型別

#include

"pch.h"

#include

#include

#include

#include

using

namespace std;

class

person

string m_name;

int m_age;};

//存放自定義型別資料

void

test01()

}//存放自定義型別 指標

void

test02()

}int

main()

vector存放內建資料型別(2)

容器 vector 演算法 for each 迭代器 vector iterator 1 include 2 include 3 include 4 using namespace std 56 為第三種遍歷方式提供函式名 7void myprint int val 811 12 vector存放內...

oracle的資料型別number存放格式

sql select smith dump smith dump smith 16 from dual smit dump smith dump smith 16 smith typ 96 len 5 83,77,73,84,72 typ 96 len 5 53,4d,49,54,48 而在trac...

STL vector容器型別

vector容器型別 vector容器是乙個模板類,可以存放任何型別的物件 但必須是同一類物件 vector物件可以在執行時高效地新增元素,並且vector中元素是連續儲存的。vector的構造 函式原型 templateexplicit vector 預設建構函式,vector物件為空 expli...