For example, I have defined the class foo and the vector vec:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class foo {
public:
foo(int flag, char ch):flag(flag), ch(ch) {}
int flag;
char ch;
};
int main(void)
{
vector<foo> vec;
vec.push_back(foo(1,'a'));
vec.push_back(foo(2,'b'));
vec.push_back(foo(3,'c'));
//blabla...
}
I've found how to find the single element: How to find an item in a std::vector?
But now I want to find an object by just giving a char, say, 'b'. How can I achieve this goal efficiently?