// Demonstrating the generic find algorithm with a vector
#include <iostream>
#include <cassert>
#include <vector>
#include <algorithm> // For find
using namespace std;
int main()
{
string x[5] = {"1234", "2345", "3456", "4567", "0987"};
vector<string> vector1(&x[0], &x[5]);
// Search for the first occurrence
vector<string>::iterator where = find(vector1.begin(), vector1.end(), "1234");
cout << *where << endl;
return 0;
}
|