对'move'的引用含糊不清



在代码的这个特定部分中,xcode查找以下错误:引用'移动'是模棱两可的。此外,它说:枚举价值"移动"未在开关中处理;这是一个胡说八道,因为包含该值的类。

while(!done){
        //m=rand()%NUM;
        for(m=0;m<NUM;++m){
            if(piece[m].onBoard()){
                sitRep=getIntel(piece,m);
                r=piece[m].recommend(sitRep);
                switch(r){
                    case nothing: break;
                    case lft: piece[mn].turnLeft(); break;
                    case rght: piece[m].turnRight(); break;
                    case rear: piece[m].aboutFace(); break;
                    case move:
                        piece[m].moveForward();
                        if(piece[m].getX()<0||piece[m].getX()>=DIM)piece[m].die();
                        if(piece[m].getY()<0||piece[m].getY()>=DIM)piece[m].die();
                        break;
                    case attck:
                        hits=piece[m].attack();
                        makeSuffer(piece,m,hits);
                        break;
                }
                if(line[0]=='q')done=true;
            }
        }

类如下:

enum provinceName {anjou, flandre, gascogne, bretagne};
enum compassPoint {U, R, D, L};
enum recommendation {move, nothing, lft, rght, rear, attck};
enum id {empty, ally, enemy, abyss};
// this struct is given to the unit when a recommendation is requested
struct intel{
    id inFront;
    int inFrontNum;
    id inRear;
    int inRearNum;
    id inLeft;
    int inLeftNum;
    id inRight;
    int inRightNum;
    compassPoint nearestEnemyDir;
    int nearestEnemyDist;
    int nearestEnemyNum;
    compassPoint weakestEnemyDir;
    int weakestEnemyDist;
    int weakestEnemyNum;
    compassPoint strongestEnemyDir;
    int strongestEnemyDist;
    int strongestEnemyNum;
    compassPoint nearestAllyDir;
    int nearestAllyDist;
    int nearestAllyNum;
    compassPoint weakestAllyDir;
    int weakestAllyDist;
    int weakestAllyNum;
    compassPoint strongestAllyDir;
    int strongestAllyDist;
    int strongestAllyNum;
};
class gamePiece{
public:
    // return the status of the alive variable
    bool onBoard();
    // return the current x value
    int getX();
    // return the current y value
    int getY();
    // return the current direction
    compassPoint getDir();
    // return the number of soldiers in the unit
    int getNumElements();
    // return the province
    provinceName getProvince();
    // set alive to false
    void die();
    // change the direction for a left turn
    void turnLeft();
    // change the direction for right turn
    void turnRight();
    // change the direction for an about face
    void aboutFace();
    // change x and y for a forward move
    void moveForward();
    // roll a die for each soldier in the unit.
    // each 5 or 6 counts as a 'hit'.
    // return the number of hits.
    int attack();
    //return lft, rght, rear, move, attck, or nothing
    recommendation recommend(intel sitRep);
    // reduce the number of soldiers by hits
    int suffer(int hits);
    // construct a nonliving gamepiece
    gamePiece();
    // construct a living gamepeice
    gamePiece(int col, int row, compassPoint direction, int num, provinceName p);
private:
    int numSoldiers;
    int x;
    int y;
    compassPoint dir;
    provinceName province;
    bool alive;
};

有人可以找出似乎是问题所在吗?谢谢。

可能是case lft:pice [mn] .turnleft();休息;?什么是MN?不应该是M吗?顺便说一句,我处于同一任务。

相关内容

  • 没有找到相关文章

最新更新