私はコースワークの戦艦プログラムを作成しており、プレーヤーの展開をデバッグしていましたが、エラーが発生したか、解決策を見つけることができませんでした:
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;
}
私は、コード全体のコンパイルで他のエラーを認識しています。