CHAPTER6-22.cpp
上传用户:fjc899
上传日期:2007-07-03
资源大小:187k
文件大小:1k
- //文件名:CHAPTER6-22.cpp
- #include <vector>
- #include <algorithm>
- #include <iostream.h>
- using namespace std;
- PrintIt(char*& AString) { cout << AString << endl; }
- int main (void)
- {
- vector<char*> Birds;
- vector<char*>::iterator NewEnd;
- Birds.push_back("cockatoo");
- Birds.push_back("galah");
- Birds.push_back("cockatoo");
- Birds.push_back("rosella");
- Birds.push_back("king parrot");
- cout << "Original vector" << endl;
- for_each(Birds.begin(), Birds.end(), PrintIt);
- NewEnd = remove(Birds.begin(), Birds.end(), "cockatoo");
- cout << "vector according to new past the end iterator" << endl;
- for_each(Birds.begin(), NewEnd, PrintIt);
- cout << endl << "Original vector now. Care required!" << endl;
- for_each(Birds.begin(), Birds.end(), PrintIt);
- }