Yeah thats exactly what I'm doing ooga, few snips of what I'm doing:
Code:
BlackJackHand::BlackJackHand()
{
// Set each of the cards, 0-4 to NULL
for (int i = 0; i < MAX_CARDS_PER_HAND; i++)
pCards[i] = NULL;
}
...
Code:
bool BlackJackHand::addCard(PlayingCard *card)
{
for (int i = 0; i < MAX_CARDS_PER_HAND; i++)
{
if (pCards[i] == NULL)
{
pCards[i] = new PlayingCard();
pCards[i]->setCard(card->getValue(),card->getSuit());
return true;
}
}
return false;
}
...
Code:
void BlackJackHand::clearHand()
{
// Loops through each card in the hand, and if its not NULL, deletes the card
for (int i = 0; i < MAX_CARDS_PER_HAND; i++)
if (pCards[i] != NULL)
{
delete pCards[i];
pCards[i] = NULL;
}
}
Right now I uncommented the delete line and have the null setup right after it now. The examples and way the teacher taught us was that just using delete was enough. But then in his examples once he deleted the pointers he didn't reuse them after. Good to know that setting them to NULL once deleted is "the way" or consider good practices.
Thanks laser, will do some research on that and start using nullptr instead.
I love learning new things.