2014-10-27 76 views
-6

不知道哪裏出錯堅持在這裏,具有包括一個if語句在我的for循環預期的函數體函數聲明

bool operator<=(string a, const Zoo& z) 
     // Pre: none 
     // Post: returns true if animal a is in Zoo z. 
     //  the owner does not count as an animal. 

      for (int i=0; i< z.count-1; i++) { 

      if (z.cage[z.count-1] == a){ 
       return true; 
      } 

      else { 
       return false; 
      } 
    } 
+0

你真的需要複製字符串嗎? – 2014-10-27 20:39:58

+6

對於我個人而言'operator <='不會是「檢查動物是否在動物園中」的合理選擇 – 2014-10-27 20:40:41

回答

11

你忘了把一個支架{在你的函數體的開始麻煩。