C ++错误:"呼叫"

时间:2014-05-07 18:38:07

标签: c++

我有问题,没有这个:

std::sort(TargetList, TargetList+targetLoop, CompareTargetEnArray());

一切都很好,但是在我上面这条线上,编译不起作用。

struct CompareTargetEnArray
{
     bool operator() (TargetList_t & lhs, TargetList_t & rhs)
     {
         return lhs.Distance < rhs.Distance;
     }
};

void Aimbot()
{
TargetList_t * TargetList = new TargetList_t[NumOfPlayers];
int targetLoop = 0;
for(int i = 0; i < NumOfPlayers; i ++)
{
    PlayerList[i].ReadInformation(i);
    if(PlayerList[i].Team == MyPlayer.Team)
        continue;

if (PlayerList[i].Health < 2)
        continue;
//PlayerList[i].Position[2] -= 10;
CalcAngle (MyPlayer.Position, PlayerList[i].Position, PlayerList[i].AimbotAngle);

TargetList[targetLoop] = TargetList_t(PlayerList[i].AimbotAngle, MyPlayer.Position,PlayerList[i].Position);

    targetLoop++; 
}
if(targetLoop > 0)
{
    std::sort(TargetList, TargetList+targetLoop, CompareTargetEnArray());

if (!GetAsyncKeyState(0x2))
    {
        WriteProcessMemory (fProcess.__HandleProcess,(PBYTE*)(fProcess.__dwordEngine + dw_m_angRotation),
                TargetList[0].AimbotAngle, 12, 0);
    }
}
targetLoop = 0;
delete [] TargetList;

}

我无法修复此问题......只删除此

    std::sort(TargetList, TargetList+targetLoop, CompareTargetEnArray());

解决了这个问题,但&#39;程序&#39;不起作用。并且不要问我为什么我正在编写某种目标机器人,仅用于我的目的。 错误:

c:\program files       (x86)\codeblocks\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_algo.h|2287|error: no  match for call to '(CompareTargetEnArray) (TargetList_t&, const TargetList_t&)'

c:\program files (x86)\codeblocks\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_algo.h|2290|error: no match for call to '(CompareTargetEnArray) (const TargetList_t&, TargetList_t&)'|

1 个答案:

答案 0 :(得分:3)

你的仿函数应该是:

struct CompareTargetEnArray {
     bool operator() (TargetList_t const& lhs, TargetList_t const& rhs) const {
     //                            ^^^^^                    ^^^^^       ^^^^^
         return lhs.Distance < rhs.Distance;
     }
};

另外,请使用std::vector