C++ examples for STL:vector
Declare an iterator to a vector<char>.
#include <iostream> #include <vector> using namespace std; void show(const char *msg, vector<char> vect); int main() {/*from w ww .ja v a 2 s . c om*/ // Declare an empty vector that can hold char objects. vector<char> v; // Declare an iterator to a vector<char>. vector<char>::iterator itr; return 0; } // Display the contents of a vector<char> by using an iterator. void show(const char *msg, vector<char> vect) { vector<char>::iterator itr; cout << msg; for(itr=vect.begin(); itr != vect.end(); ++itr) cout << *itr << " "; cout << "\n"; }