this is my addCard function which takes a playingCard as a parameter then hands over the address of its self to an allocated array of pointers to playingCard objects.
void cardHand::addCard(playingCard card) {
theHand[nElems++] = &card;
} // addCard()
now when i run my program it runs fine but then crashes when the destructor is called.
cardHand::~cardHand() {
for(int c = 0;c<MAX;c++) {
if(theHand[c] != NULL)
delete theHand[c]; // here is the problem
}
delete [] theHand;
} // class destructor
is it crashing because I'm only handing over the address of the playingCard object in the addCard function. should it be a pointer instead?