我有問題,如果沒有這個:C++錯誤:「不匹配調用」
std::sort(TargetList, TargetList+targetLoop, CompareTargetEnArray());
一切工作正常,但此行我之上,compilating不起作用。
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());
解決了問題,但 '程序' 不propertly工作。不要問我爲什麼我寫了一個類似的目標,只爲我的目的。 錯誤:
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&)'|
如果可以,請發佈完整的錯誤消息 – Avery
使參數引用同樣適用於operator()成員const。 – WhozCraig