mercredi 4 novembre 2015

error: expected unqualified-id before if

I have looked through previous answers, but none of them have explained why I am getting this error.

Here is my code with the error. It occurs on "if(pathID==2...)" and every if statement after that.

void add_path(int a,int b, int current_step,int pathID){

    if(pathID == 0){
            path[current_step] = new step(a,b,"Filled A",path[current_step]);
    }
    if(pathID == 1)
            path[current_step] = new step(a,b,"Filled B",path[current_step]);
    }
    if(pathID == 2){
            path[current_step] = new step(a,b,"Empty A",path[current_step]);
    }
    if(pathID == 3){
            path[current_step] = new step(a,b,"Empty B",path[current_step]);
    }
    if(pathID == 4){
            path[current_step] = new step(a,b,"Pour B to A",path[current_step]);
    }
    if(pathID == 5){
            path[current_step] = new step(a,b,"Pour A to B",path[current_step]);
    }
}

All this code is meant to do is add to the linked list at a given position in an array. The pathID is passed in and tells it what action was performed, so we know we know what to add to the linked list.

Later in the program I use that linked list to determine what actions were taken. I still need to make it a doubly linked list so it does not print in reverse, but that's another problem.

Aucun commentaire:

Enregistrer un commentaire