How to start .. I have a vector of objects. I´d like to sort the vector by different things like name, etc. If I understood right, using sort algorithm like this only
sort(persons.begin(), persons.end())would basically use my overloaded " operator< ". My question is how can I tell the sort algorithm that it would sort the vector by name or by other part of the object? I found this site on the net: http://msdn.microsof...x(v=vs.80).aspx
As I see the parameters of the operator function are only the objects of the vector and it´s only written in the function by which part of object it should sort the vector. I could write more operator functions but how would the algorithm know which one to call? It´s kind of hard for me to get familiar with the object oriented part so I appreciate any help. Thanks!

New Topic/Question
Reply



MultiQuote



|