template <class InputIterator, class X> InputIterator::difference_type count( InputIterator qFirst, InputIterator qLast, const X& kxrValue );
#include <algorithm>
#include <iostream>
#include <vector>
#include <algorithm>
int main()
{
using namespace std;
// Create a vector instance
vector<char> qV;
qV.push_back('X');
qV.push_back('o');
qV.push_back('a');
qV.push_back('X');
qV.push_back('.');
qV.push_back('n');
qV.push_back('e');
qV.push_back('t');
vector<char>::iterator qIter;
// Output the vector
cout << "Vector: ";
for (qIter = qV.begin(); qIter != qV.end(); ++qIter) {
cout << *qIter;
}
cout << endl;
// Count the 'X's and output the number
vector<char>::iterator::difference_type qCount;
qCount = count(qV.begin(), qV.end(), 'X');
cout << "There are " << qCount << " X's in V." << endl;
// Keep the window open
cin.get();
return 0;
}
© 20072025 XoaX.net LLC. All rights reserved.