I'm having a problem sorting my derived classes with the STL sort function.
Example -
The header:
vector<AbstractBaseClass *> *myVector;
In the ImpL:
sort(myVector->begin(), myVector->end(), compareBy);
The comparator:
bool MyClass::compareBy(AbstractBaseClass& a, AbstractBaseClass& b) {
return (a->someMethod() < b->someMethod());
}
Edit: This question is geared toward general usage of sorting abstract classes with the STL (I'm not posting a trace dump). If its not apparent already, I'll say that there is no way in hell it can compile as printed. Rather, I'm asking (given the data structures) how one would typically sort with this toy abstract class.
Thanks for the quick answers, I believe you guys already nail'd it!
Got'a love StackOverFlow!