2012-11-07 37 views
0

在此代碼的特定部分中,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; 

}; 

是否有人可以找出什麼似乎是問題嗎? 謝謝。

回答

1

可能它是殼體LFT:件[MN] .turnLeft();打破;?最新的mn?是不是應該是m?順便說一句,我在同一個任務上。

+0

感謝您的提示!雖然不能弄清楚任務:) – user1563544