Note that there are some explanatory texts on larger screens.

plurals
  1. POMultidimensional Array trouble (bounds)
    primarykey
    data
    text
    <p>here is the code with the problem:</p> <pre><code>#ifndef WEAPONS_H_INCLUDED #define WEAPONS_H_INCLUDED #include "Battleship header.h" void Player::torpedo(string enemyEvtTracker[][10], string myhitboard[][10]) { string bcn; //board column number cout &lt;&lt; "Enter board column number (1-9): "; cin &gt;&gt; bcn; flush(); if(bcn!="1"&amp;&amp;bcn!="2"&amp;&amp;bcn!="3"&amp;&amp;bcn!="4"&amp;&amp;bcn!="5"&amp;&amp;bcn!="6"&amp;&amp;bcn!="7"&amp;&amp;bcn!="8"&amp;&amp;bcn!="9") {cout &lt;&lt;endl&lt;&lt; "That is not a valid number.";} return; } #endif // WEAPONS_H_INCLUDED </code></pre> <p>here is the class Player:</p> <pre><code>#ifndef BATTLESHIPPLAYERCLASS_H_INCLUDED #define BATTLESHIPPLAYERCLASS_H_INCLUDED using namespace std; class Player // define a class for a player { void torpedo(string enemyEvtTracker[10][10], string myhitboard[10][10]); void cannon(); void scatter(); void menu(); friend int main(int, char*[]); //Let main access the protected members friend int routine_END(void); public: void displaydata() {cout &lt;&lt; money &lt;&lt; endl &lt;&lt; gunpowder &lt;&lt; endl &lt;&lt; ammo_cannon &lt;&lt; endl &lt;&lt; ammo_4hit &lt;&lt; endl;} string savename; int gunpowder; int ammo_cannon; int ammo_4hit; string gun_4; int ammo_scatter; string gun_s; int money; Player(string name){money=18000; gunpowder=100;ammo_cannon=20; ammo_4hit=0; ammo_scatter=0; gun_4="OFF"; gun_s="OFF";playername=name;} //Define the constructor void simplegame(void) {gunpowder=99999999; ammo_cannon=999999999; ammo_scatter=4; gun_s="ON";} void getname(string *playername, int option) { if (option==1) {cout &lt;&lt; "Enter your name here player 1:"; cin &gt;&gt; *playername;} else {cout &lt;&lt; "Enter your name here player 2:"; cin &gt;&gt; *playername;} } string playername; char mainRowGuess; int check_transaction (int mymoney, int moneyowed) { if (mymoney-moneyowed&lt;&lt;0) {return 0;} else {return 1;} } void change_Answer_to_number(char row,int* outputRow) { if (row=='A'||row=='a'){*outputRow =1;} else if (row=='B'||row=='b'){*outputRow =2;} else if (row=='C'||row=='c'){*outputRow =3;} else if (row=='D'||row=='d'){*outputRow =4;} else if (row=='E'||row=='e'){*outputRow =5;} else if (row=='F'||row=='f'){*outputRow =6;} else if (row=='G'||row=='g'){*outputRow =7;} else if (row=='H'||row=='h'){*outputRow =8;} else if (row=='I'||row=='i'){*outputRow =9;} else {*outputRow = 0;} } void changeCharToNumber(char row, int* outputRow) { if (row=='1'){*outputRow=1;} else if (row=='2'){*outputRow=2;} else if (row=='3'){*outputRow=3;} else if (row=='4'){*outputRow=4;} else if (row=='5'){*outputRow=5;} else if (row=='6'){*outputRow=6;} else if (row=='7'){*outputRow=7;} else if (row=='8'){*outputRow=8;} else if (row=='9'){*outputRow=9;} else {cout &lt;&lt; "Unexpected Error." &lt;&lt; endl; *outputRow=0;} } char airRowStart; char airColStart; char aircraftDirec; char destRowStart; char destColStart; char destroyerDirec; char subRowStart; char subColStart; char subDirec; char patrolStart; char patrolDirec; /// START MENU FUNCTION void error_money(void) {cout &lt;&lt; "Not enough money!";} char startRowAircraftCarrier; char startRowDestroyer; char startRowSub; char startRowPatrolBoat; friend int routine_END (void); friend void menu (int* gunpowder, int* ammo_cannon, int* ammo_4hit, int* ammo_scatter, int* money, string* gun_4, string* gun_s); }; #endif // BATTLESHIPPLAYERCLASS_H_INCLUDED </code></pre> <p>and this generates the following build log...</p> <blockquote> <h2>-------------- Build: Debug in Advanced Battleship Obj</h2> <p>[ 50.0%] Compiling: main.cpp C:\Advanced_Battleship_Revised_5111\main.cpp:32: warning: ignoring #pragma comment In file included from C:\Advanced_Battleship_Revised_5111\/imputoutput.h:9, from C:\Advanced_Battleship_Revised_5111\/Battleship header.h:3, from C:\Advanced_Battleship_Revised_5111\main.cpp:25: C:\Advanced_Battleship_Revised_5111\/BattleshipPlayerClass.h:74: warning: 'int routine_END()' is already a friend of class 'Player' C:\Advanced_Battleship_Revised_5111\/BattleshipPlayerClass.h: In member function 'int Player::check_transaction(int, int)': C:\Advanced_Battleship_Revised_5111\/BattleshipPlayerClass.h:33: warning: suggest parentheses around '-' inside '&lt;&lt;' In file included from C:\Advanced_Battleship_Revised_5111\main.cpp:27: C:\Advanced_Battleship_Revised_5111\/BattleshipMenu.h: In member function 'void Player::menu()': C:\Advanced_Battleship_Revised_5111\/BattleshipMenu.h:118: warning: label 'GUNPOWDER_MENU_1' defined but not used C:\Advanced_Battleship_Revised_5111\/BattleshipMenu.h:166: warning: label 'CIN_WEAPON_OPTION_SCATTER_CANNON' defined but not used In file included from C:\Advanced_Battleship_Revised_5111\main.cpp:30: C:\Advanced_Battleship_Revised_5111\/weapons.h: At global scope: <strong>> C:\Advanced_Battleship_Revised_5111\/weapons.h:5: error: declaration of 'enemyEvtTracker' as multidimensional array must have bounds for all dimensions except the first C:\Advanced_Battleship_Revised_5111\/weapons.h:5: error: expected ')' before ',' token C:\Advanced_Battleship_Revised_5111\/weapons.h:5: error: expected constructor, destructor, or type conversion before ',' token C:\Advanced_Battleship_Revised_5111\/weapons.h:5: error: expected constructor, destructor, or type conversion before 'myhitboard' Process terminated with</strong> status 1 (0 minutes, 1 seconds) 4 errors, 5 warnings</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload