I have a set of pointers to a custom class myClass:
set<myClass*> s;
I'm trying to use std::find
to verify whether an object O
of type myClass *
is contained within the set, but this doesn't appear to be working- I think find
might only work for objects and not pointers to objects? Is there any way to make this work? I tried dereferencing the pointer but then I realized that obviously wouldn't work since my set
is one of pointers to objects anyway.
set<myClass*> s;
/* set gets filled up with objects of type myClass */
myClass *O = new myClass();
if(s.find(O) != s.end())
cout<<"Found!\n";
I've manually printed out the members of O
and an object already in the set, and I know they're identical. So this code should be printing "Found!" But it's not.