For example,
#include <set>
class myclass
{
public:
int a;
};
int main()
{
std::set<myclass*> arr;
for(m=0;m<3; m++){
myclass * p = new myclass;
p->a=m;
arr.insert(p);
}
}
In the above code, arr
is sorting the address rather than the value a
. How to make arr
's member rank according the value of a
.