c++ - Calling member function of an object inside a vector -
this continuation on previous question here regarding retrieving , editing private members of objects in vector.
i have vector full of objects have private members need access. i have created accessor functions returning each private member , looking best way iterate through vector of objects, returning specific private member , comparing given variable until match found.
i have considered using find_if
have had no luck using member functions return value, each object in vector, criteria.
neither have been able use for_each
job.
the reason creating additional question i've been dwelling longer should , it's getting become quite urgent find solution problem. nudge in right direction appreciated!
create functor:
struct compareto{ compareto(const anotherobject& avalue) : thevalue(avalue){} bool operator()(const object& anobject) const{ return anobject.getmembervar() == thevalue; } const anotherobject& thevalue; };
that can put find_if
.
Comments
Post a Comment