函数声明符后面应为函数体

Expected function body after function declarator

本文关键字:函数体 声明 函数      更新时间:2023-10-16

不确定错误持续存在的位置,在我的for循环中包含if语句时遇到问题

 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;
           }
    }

您忘记在函数体的开头放一个括号{