這段代碼的問題,我採取上述錯誤?錯誤:在'。'之前預期的初級表達式令牌
TIA
#include"PositionInfo.h"
bool DecisionTree::Decision(Agent & agent) {
PositionInfo Player_position;
double metr=Player_position.GetBallDistToTeammate(5);
if (agent.GetSelf().IsKickable()) {
Kicker::instance().KickBall(agent,agent.GetWorldState().GetTeammate(5).GetPos(),metr);
}
}
我現在改變了代碼,我得到這個錯誤:
錯誤:調用沒有匹配的函數 'PositionInfo :: PositionInfo()'
編輯:
根據johnsyweb迴應:
class Positi onInfo我們有這樣的:
PositionInfo(WorldState *pWorldState, InfoState *pInfoState);
我把它像這樣在DecisionTree:
PositionInfo Player_position(WorldState *pWorldState, InfoState *pInfoState);
double met=Player_position//but here IDE doesnt let me to put GetBallDistToTeammate()
您需要*閱讀''PositionInfo.h''中的代碼*以找出PositionInfo的構造函數的參數並提供這些參數,按照我的答案。 – Johnsyweb 2011-03-22 10:54:08
'PositionInfo Player_position(WorldState * pWorldState,InfoState * pInfoState);'是不正確的語法。你需要在這裏傳遞指向有效對象的指針(假設'PositionInfo Player_position(NULL,NULL);'將不會產生任何有用的結果 – Johnsyweb 2011-03-22 11:42:44