You could declare the deck in main() and pass it by reference to deckFunction to initialize it.
Notice how you had to declare an instance of a CardClass object (line 58) just so you could call the deckFunction() function?
Maybe make an INITdeck() function outside of any class instead. Call it from main() to setup the deck. Pass the deck by reference to this function too.
There will be similar problems coming up with other variables local to player1Hand().
How will the pot grow as each player bets?
How do you keep track of each players chips for more than one round of play?
The players class you wrote includes a special function for each player. This isn't how the class model is intended to work.
A class is a model for a single object of some type.
A Player class should model a single player. It would hold data for the player, like his number of chips, cards held in his hand, etc. It would also define methods (functions) for things a Player must do, like getHand(), showHand(), etc.
You might then declare an array of Players in main().
As an example, by no means complete or a best design:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
class Player
{
public:
int chips;
card Hand[maxInHand];// where maxInHand is a constant defined somewhere
int numCardsHeld;
bool inGame;
int getHand( card deck[], int& cardsLeft );// returns amount bet?
void showHand();
private:
// maybe some of the above members
};
|
Other issues are apparent. Eg. Use of rand()%52 to select a card from the deck will sometimes result in more than one of the same card dealt. Call random_shuffle() on the deck in INITdeck() then deal the cards in order?