错误:期待';' 在括号之前

use*_*907 -2 c++ compiler-errors syntax-error

嘿伙计们,我的大脑已经正式进入所有这些项目,因为我似乎可以找出这个相对简单的错误.

所以我遇到的问题是它要求我在curli括号之前添加一个分号,这里是它发生的代码段.

bool IsAlive(int row, int col){
        return true;
    }
Run Code Online (Sandbox Code Playgroud)

它是在'col)之后问我一个分号.这是完整的代码

#include <iostream>
#include <windows.h>

#define NumGen 1
#define NumRows 13
#define NumCol 13

using namespace std;


void main()
{
    const int NumModRows=NumRows+2;
    const int NumModCol=NumCol+2;
    int grid[NumGen][NumModRows][NumModCol]={0};
    grid[NumGen][0][0]=5;
    //cout<<"Hey this is number "<<grid[NumGen][0][0]<<endl;
    //int upLeft=-1, upMid=-1, upRight=-1, left=-1, right=-1, botLeft=-1, botMid=-1, botRight=-1;
    //cout<<"All: "<<upLeft<<", "<<upMid<<", "<<upRight<<", "<<left<<", "<<right<<", "<<botLeft<<", "<<botMid<<", "<<botRight<<endl<<endl;
    //get input from user

    int rowInput;
    int colInput;
    int numInputs;
    cout<<"how many inputs will be inserted in the grid?(in row then col format)"<<endl;
    //get user inputs where the gen 0 cells are alive
    for(int i=0; i<numInputs;i++)
    {
        cout<<"The row of input"<<endl;
        cin>>rowInput;
        cout<<"The col of input"<<endl;
        cin>>colInput;
        grid[NumGen][rowInput][colInput]=1;
    }

    //bool isAlive(int, int);
    bool IsAlive(int row, int col){
        return true;
    }



    //cin.get();

    Sleep(10000);

}
Run Code Online (Sandbox Code Playgroud)

tao*_*ocp 8

不能isAlive在里面定义另一个函数main.

您可以尝试将isAlive函数的定义移到外部main,然后main在必要时调用函数.