IntelliSense Errors

Ok, so in short, Im doing A level computing, and for my coursework I'm writing Battleships.

So far all's been going well, but recently, I have added a 'Validmove' procedure. Its saying that it "cannot determine which instance of overloaded function "Validmove" is intended".

I have two procedures, one is Validmove and the other is Validmove2 (as there are two arrays (for each players grid) so Validmove checks one array and Validmove2 checks the other.)

"IntelliSense: no instance of overloaded function "shipplacement" matches the argument list"
Is the next error I am getting, and well... I do not know where I'm going wrong, I have declared the Procedure and written it...

Thank you for any help you can offer!
How can anyone help you, without seeing your code?
Ok, ill copy it...

void Validmove(int Xcoordinate, int Ycoordinate, char gameboard[10][10]);
void Validmove2(int Xcoordinate, int Ycoordinate, char gameboard2[10][10]);
void hitmiss(int Xcoordinate, int Ycoordinate, char gameboard[10][10]);
void shipplacement(int Xcoordinate, int Ycoordinate, char shipboard[10][10]);
char gameboard[10][10];
char gameboard2[10][10];
char shipboard[10][10];
char shipboard2[10][10];

void main(void){
shipplacement(Xcoord, Ycoord);
//Gets coordinate for player ones shot and checks if valid firing position
Getcoord(Xcoord, Ycoord);
Validmove;

while(checkmove != 1){

cout << "You cannot shoot outside of the battlezone. Please select new coordinates." << endl;
Sleep(2000);
Getcoord(Xcoord, Ycoord);
Validmove;
}
// checks if hit or miss and displays appropriate symbol
Hitmiss;
cout << Hitmiss << gameboard[Xcoord][Ycoord];
Displaygameboard(gameboard);


Getcoord(Xcoord, Ycoord);
Validmove2;

while(checkmove != 1){

// gets coordinate for player 2 shot and check if valid firing position


cout << "You cannot shoot outside of the battlezone. Please select new coordinates." << endl;
Sleep(2000);
Getcoord(Xcoord, Ycoord);
Validmove2;

}
// checks if hit or miss and displays appropriate symbol
Displaygameboard2(gameboard2);
}

void Validmove(int &Xcoordinate, int &Ycoordinate, char gameboard[10][10]){
checkmove = 1;
if((Xcoord<0) || (Xcoord>9)){
checkmove = 0;
}
if((Ycoord<0) || (Ycoord>9)){
checkmove = 0;
}
if((gameboard[Xcoord][Ycoord] == 'X') || (gameboard[Xcoord][Ycoord] == 'O')){
checkmove = 0;
}

}
void Validmove2(int &Xcoordinate, int &Ycoordinate, char gameboard2[10][10]){

checkmove2 = 1;
if((Xcoord<0) || (Xcoord>9)){
checkmove2 = 0;
}
if((Ycoord<0) || (Ycoord>9)){
checkmove2 = 0;
}
if((gameboard2[Xcoord][Ycoord] == 'X') || (gameboard2[Xcoord][Ycoord] == 'O')){
checkmove2 = 0;
}

}

void hitmiss(char shipboard[10][10]){
int Xcoord, Ycoord;
if(char shipboard[Xcoord][Ycoord]='s'){
Hitmiss ='X';
}
else{
Hitmiss ='O';
}
}

void shipplacement(char shipboard[10][10]){
int p1ship1 =1;
int p1ship2 =1;
cout << "Please place a ship point" << endl;
cin >> p1ship1;
cout << endl;
cin >> p1ship2;
cout << 's' << shipboard[p1ship1][p1ship2];


}

There are a few other procedures but as they don't relate to the issues im having I've left them out.
You originally asked about a particular problem, with function shipplacement

What I see here is the prototype:
void shipplacement(int Xcoordinate, int Ycoordinate, char shipboard[10][10]);
and the definition:
1
2
3
4
void shipplacement(char shipboard[10][10])
{
// etc
}


Notice the parameter lists are different. They should match, in the number and type of each parameter.

And then in function main(), there is a call to the function shipplacement(Xcoord, Ycoord);

The number and type of the parameters in the call doesn't match either of the previous two versions.

You need to consider the design of the function, what parameters does it require, in order to work. Then use those in the function definition.
After that, copy and paste from the definition, to give you the prototype.
And last but not least, make sure that when you call the function, the parameters you pass match those you previously specified.
(the names of the parameters may change, but the number, type and order must agree in each of the three usages).

As for validmove, you have defined the function, but in function main() rather than calling it with the required parameters, the code simply states the function name, like this: Validmove;. In order to call the function, you need to add the parentheses and the parameters which are required by the function.
Last edited on
Thank you very much! will let you know how I get on :)

edit:
I have fixed the Validmove functions now, thank you for your help!
Last edited on
Topic archived. No new replies allowed.