Populating array of objects with cards

1
2
3
4
5
6
7
8
9
10
11
12
13
Hand test[1];
   Hand *hand2_objects = new Hand[numPlayers];
   
   for ( int i = 0; i < 52; i++ )
   {
      test_card = deck_game.dealCard();
      test[0].setTakeCard(test_card);
   }  
   //If two players...
   //hand2_objects[0] = ???;
   //hand2_objects[1] = ????;

   cout << test[0].toStringV() << endl;


Let's say that I have dynamically allocated two hand_objects, meaning that there are two players in the game. The loop creates creates 52 cards and puts it in an object in array test[0]. Because the number of players vary, how do I create a loop that will populate the number of the hand_objects array, where each position of the array represents a players cards?

For example, hand_objects[0] is Player 1's HAND, containing the first 26 cards, and hand_objects[1] is Player 2's HAND, containing the rest of the 26 cards of the deck.
Last edited on
Topic archived. No new replies allowed.