My priority queue declared as:
std::priority_queue<*MyClass> queue;
class MyClass {
bool operator<( const MyClass* m ) const;
}
Since your priority_queue
contains only pointer values, it will use the default comparison operator for the pointers - this will sort them by address which is obviously not what you want. If you change the priority_queue
to store the class instances by value, it will use the operator you defined. Or, you will have to provide a comparison function.