That does not appear to work precisely as you have indicated, so I used an uninitialized vector and initialized it with a for loop in the constructor. seems to work fine.
declaration
1 2 3 4 5 6 7 8 9 10
class Game
{
private:
Deck m_deck;
std::vector<Hand> hands; // line in question here
public:
Game();
};
defintion
1 2 3 4 5
Game::Game()
{
for(int i = 0; i < NUM_PLAYERS; i++)
hands.push_back(Hand(m_deck));
}
note: I haven't properly tested this code, but I have checked in the debugger that everything is properly initialized after it is called (ie. Game g)
Yes, Hand's constructor calls the referenced Deck objects Deal member function, which in turn modifies a counter in the Deck object. If this was not the case, the code you provided would work?