Eri*_*pir 3 c++ operator-overloading
我需要B类才能拥有AToTime对象的最小优先级队列.
AToTime有operator>,然而我收到错误告诉我,而不是没有运算符>匹配操作数...
#include <queue>
#include <functional>
using namespace std;
class B
{
public:
B();
virtual ~B();
private:
log4cxx::LoggerPtr m_logger;
class AToTime
{
public:
AToTime(const ACE_Time_Value& time, const APtr a) : m_time(time), m_a(a){}
bool operator >(const AToTime& other)
{
return m_time > other.m_time;
}
public:
ACE_Time_Value m_time;
APtr m_a;
};
priority_queue<AToTime, vector<AToTime>, greater<AToTime> > m_myMinHeap;
};
Run Code Online (Sandbox Code Playgroud)
bool operator >(const AToTime& other)
Run Code Online (Sandbox Code Playgroud)
它应该是一个const函数.
bool operator >(const AToTime& other) const
Run Code Online (Sandbox Code Playgroud)