#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
vector<char> vectorObject;
vector<char>::iterator p, p_end;
int i;
for(i = 0; i <5; i++) {
vectorObject.push_back('A'+i);
vectorObject.push_back('A'+i);
vectorObject.push_back('A'+i);
}
cout << "Original contents of vectorObject:";
for(p = vectorObject.begin(); p < vectorObject.end(); p++)
cout << *p << " ";
cout << endl;
p_end = remove(vectorObject.begin(), vectorObject.end(), 'C'); // remove all C's
cout << "Sequence after removing all C's:";
for(p = vectorObject.begin(); p < p_end; p++)
cout << *p << " ";
cout << endl;
replace(vectorObject.begin(), vectorObject.end(), 'D', 'X'); // replace D's with digits X's
cout << "Sequence after replacement:";
for(p = vectorObject.begin(); p < p_end; p++)
cout << *p << " ";
cout << endl;
return 0;
}
|