我在cpp文件中有投票方法,如下面的方法:
void CMOReplicationlayer::Voting(std::list<CMOData*>* pa_repQueue, CMOData* pa_votedData)
{
pa_repQueue->sort(&CMOReplicationlayer::compare_d);
pa_votedData = pa_repQueue->front();
}
我在头文件中有CMOData struct
,如下所示:
struct CMOData
{
TForteByte* pa_pvData = NULL;//Received data serialization byte
unsigned int pa_unSize = 0;//The size after adding Date & Time
CIEC_TIME* pa_Offset = NULL;//Offset Value
TForteUInt64 pa_recvDateTime = NULL;
bool operator()(CMOData first, CMOData second)
{
bool result = false;
if (first.pa_recvDateTime == second.pa_recvDateTime)
result = true;
return result;
}
};
和compare method
是这样的:
bool compare_a(const CMOReplicationlayer::CMOData& first, const CMOReplicationlayer::CMOData& second)
{
return first.pa_recvDateTime < second.pa_recvDateTime;
}
bool compare_d(const CMOReplicationlayer::CMOData& first, const CMOReplicationlayer::CMOData& second)
{
return first.pa_recvDateTime > second.pa_recvDateTime;
}
但我在cpp文件中没有t know why I get this error when I want to use
排序列表方法。
"error C2064: term does not evaluate to a function taking 2 arguments"