Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Do you want to know how to pass arguments?</p> <p>You seem to be new to C++. You may want to read a little about functions.</p> <p><a href="http://www.cplusplus.com/doc/tutorial/functions/" rel="nofollow">Functions (I) On Cplusplus</a></p> <p><a href="http://www.cplusplus.com/doc/tutorial/functions2/" rel="nofollow">Functions (II) On Cplusplus</a></p> <pre><code>struct box{ //code }; //forgot semicolon void checker(box A, box B, box C, box D, box E, box Q){ //code } void display() //forgot parenthesis { box A, B, C, D, E, Q; //initialize and use variables. //call function... checker(A, B, C, D, E, Q); } </code></pre> <p>It's hard to tell what exactly you are asking.</p> <p><b>An idea.</b></p> <p>Maybe you want something like this (taking a wild guess here. Mostly just showing you one scenario.):</p> <pre><code>class Box { //code }; class GameState { public: GameState(map&lt;std::string, Box&gt; _boxes); void display(); void moveBox(std::string boxID, int x, int y); private: bool checkMove(std::string boxID, int x, int y); std::map&lt;std::string, Box&gt; boxes; }; void mainLoop() { map&lt;string, Box&gt; boxes; boxes["A"] = Box(); boxes["B"] = Box(); boxes["C"] = Box(); boxes["D"] = Box(); boxes["E"] = Box(); boxes["Q"] = Box(); bool quit = false; GameState game(boxes); while(true) { int action = game.getAction(); switch(action) { case DISPLAY_ACTION: game.display(); break; case MOVE_ACTION: string boxId; int x, y; //get those somehow... game.moveBox(boxId, x, y); break; case QUIT; quit = true; break; } if (quit) break; } } int GameState::getAction(box&amp; aBox) { //return some action code } bool GameState::checkMove(string boxId, int x, y) { //check box } void GameState::display() { } void GameState::moveBox(string boxId, int x, int y) { if (checkMove(boxId, x, y)) { //more code } } </code></pre>
    singulars
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      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