Say I have a class myClass
with 3 attributes in the constructor (string value
, int pos
, int pos_2
).
Now I make a vector
of objects of said class.
How would I search through vector<myClass>
to find the index of any class objects with a string
that matches a given string
?
Example:
Here's a (non-functional) attempt at finding a class object that has the string hello
as its string value
:
std::string to_find = "hello";
std::vector<myClass>::iterator duplicate_it;
duplicate_it = std::find(subrelation_vector.begin()->value, subrelation_vector.end()->value, to_find);
int duplicate_pos = *duplicate_it->pos;