Not returning the correct output


Hi.
Below is my code for a deck of cards program. It only returns "Of" and does not return the face or suit I am looking for. I am able to see the face and suit values get updated when i debug lined 16-22 individually in Card.cpp. I do not get any compiling errors or warnings.

I think there is an error in DeckOfCards.cpp lines 63-88, but I am not sure where. Any help would be greatly appreciated!

Last edited on
The problem is in the constructor of thie class DeckOfCards. deck is a local variable (line 16/22/28/33). It does not affect the member array. Change it like so:
1
2
3
4
5
6
7
8
9
10
11
12
DeckOfCards::DeckOfCards() //create the deck of cards so we can access it
{
int dec_idx = 0;
	for (int index = 0; index < 13; index++)  //create club cards
	{
		deck[dec_idx++] = Card(index, 0);

	}

...

}
Thank you!! That fixed my problem!
Topic archived. No new replies allowed.