// 要素の参照に iterator を使用。 // STL では コンテナの内容を扱う際に iterator を使用します。 #include <iostream> #include <vector> using namespace std; int main( ) { cout << "[vector03] iterator" << endl ; vector<int> iVec; cout << "vector size = " << iVec.size( ) << endl ; iVec.push_back( 10 ); iVec.push_back( 9 ); iVec.push_back( 8 ); cout << "vector size = " << iVec.size( ) << endl ; for ( vector<int>::iterator i = iVec.begin( ) ; i != iVec.end( ) ; i++ ) { cout << *i << endl ; } return 0; } // ポインタのようなものと考えていますが、実は奥が深いです。1 // end( ) で獲得したイテレータは最終要素+1 を指していることに注意 // end of file