// 個人的によく使う、vector<string> の基本操作 // BASIC の文字列のような感覚です。 #include <iostream> #include <algorithm> #include <vector> #include <string> using namespace std; int main( ) { cout << "[vector11] vector<string>" << endl ; vector<string> sVec; cout << "vector size = " << sVec.size( ) << endl ; sVec.push_back( "pyrite" ); sVec.push_back( "calcite" ); sVec.push_back( "spinel" ); cout << "vector size = " << sVec.size( ) << endl ; for ( vector<string>::iterator i = sVec.begin( ) ; i != sVec.end( ) ; i++ ) { cout << *i << endl ; } vector<string>::iterator first = sVec.begin( ); vector<string>::iterator last = sVec.end( ); cout << "size( ) = " << sVec.size( ) << endl ; cout << "max_size( ) = " << sVec.max_size( ) << endl ; cout << "capacity( ) = " << sVec.capacity( ) << endl ; return 0; } // char型より、ずいぶん楽になります。 // end of file