我正在为课程作业制作战舰程序,并且正在调试玩家的部署我遇到了一个我无法或找到解决方案的错误:
bb.cpp:12: error: previous declaration of ‘int vert(int*, std::string)’
我已经在我的代码中搜索了任何以前对 int vert 的引用,但找不到任何东西。
这是函数原型
//game function prototypes
int deploy();
int firing();
int gridupdte();
int win = 0;
int vert(int *x, string sa);
int hor(int *y, string s);
int check();
这是函数vert:
int vert(*shipx, shiptype) //Calculates where the bow of the ship should be (the pointy bit)
{
int shiplen;
int bow;
switch(shiptype) // Determines the length to add to the y co-ordinate
{
case "cv" : shiplen = 5; break;
case "ca" : shiplen = 4; break;
case "dd" : shiplen = 3; break;
case "ss" : shiplen = 3; break;
case "ms" : shiplen = 2; break;
}
bow = *shipx + shiplen;
*shipx = bow;
return *shipx;
}
int hor (*shipy, shiptype) //Calculates where the bow of the ship should be (the pointy bit)
{
int shiplen;
int bow;
switch(shiptype) // Determines the length to add to the x co-ordinate
{
case "cv" : shiplen = 5; break;
case "ca" : shiplen = 4; break;
case "dd" : shiplen = 3; break;
case "ss" : shiplen = 3; break;
case "ms" : shiplen = 2; break;
}
bow = *shipy + shiplen;
*shipy = bow;
return *shipy;
}
我知道编译整个代码的其他错误。