I have a vector which contains class objects of classObjects
vector<classObjects> classObjectVector;
I am trying to use std::find to search for a record in my vector, but I get an error
message
error
Invalid operands to binary expression
due to this line.
if (std::find(classObjectVector.begin(), classObjectVector.end(), "aElement") != classObjectVector.end())
{
//found
}
do I have to do something addtional to make it work?
I might have guess that I might need to do perhaps a operator overloading
something like this
friend bool operator () (classObjects &objectOne) {
return (objectOne);
};
and after that I will intialize it like this
if (std::find(classObjectVector.begin(), classObjectVector.end(), classObjects("aElement")) != classObjectVector.end())
{
//found
}
I am not really sure how should I use std::find with a vector containing class objects. I just made some assumptions.Need help and advice. thanks