I'm trying to create a constructor for a Deck class which has only one field: a pointer to a node class object. A node has two fields, a card object and a pointer to another node (linked list).
I'm trying to build a deck of cards using this construct but when I print it, it only displays one card, leading me to believe that the constructor doesn't work properly.
My printing method works fine, I've tested it with other examples. I'm intentionally starting the deck with the same card twice as I was going to remove it later.
Deck::Deck(){
node* phead;
phead = new node(Card("A","Heart"));
node* curr;
node* next;
curr = phead->next;
string suits[4] {"Heart", "Spade", "Club", "Diamond"};
string values[13] {"A","2","3","4","5","6","7","8","9","10","J","Q","K"};
for(int i = 0; i < 4; i++){
for(int j = 0; j < 13; j++){
curr = new node();
curr->card = Card(values[j], suits[i]);
next = curr->next;
curr = next;
}
}
curr=NULL;
deck = phead;
}