begin
提供:cppreference.com
Syntax:
#include <vector> iterator begin(); const_iterator begin() const;
begin()関数はベクタの最初の要素へのiteratorを返却する。また、 定数時間で動作する。
例えば、次のコードはbegin()関数を使ってベクタの要素を走査するiteratorを初期化している。
vector<string> words; string str; while( cin >> str ) words.push_back(str); for( vector<string>::const_iterator iter = words.begin(); iter != words.end(); ++iter ) { cout << *iter << endl; }
次の入力が与えられた時:
hey mickey you're so fine
上記のコードは次の出力をする:
hey
mickey
you're
so
fineRelated Topics: [] operator, at, end, rbegin, rend