I am trying to use vectors and classes to write a card class an expand my experience with these. My issue is when I try and print out the whole deck i just get a repeating value of -858993460. My expected value would be something like 4H or 12S.
// CardClass.cpp : Defines the entry point for the console application.
//
#include "Card.h";
#include <vector>;
void fillDeck(vector<Card>&);
//fillDeck - build a new deck
//@parm vector<Card>& - cards in deck
void printDeck(vector<Card>&);
int main()
{
int holder;
vector <Card> Deck;
fillDeck(Deck);
printDeck(Deck);
cin >> holder;
return 0;
}
void printDeck(vector<Card>& deck) {
unsignedint i = deck.size();
for (unsignedint x = 0; x < i; x++) {
cout << deck[x].getSuit() << deck[x].getValue() << endl;
}
}
void fillDeck(vector<Card>& newDeck) {
//the variables we will be using to fill the deck
char suit;
int value;
//Two for loops to run through 13 cards in all four suits
for (int i = 0; i < 4; i++) {
for (int x = 0; x < 13; x++) {
//Define our suits
switch (i) {
case 0: suit = 'H';
break;
case 1: suit = 'D';
break;
case 2: suit = 'S';
break;
case 3: suit = 'C';
break;
}
//value of new card
//x + 1 because x starts at 0
value = x + 1;
//cout << suit << value << endl;
Card newCard (suit, value);
newDeck.push_back(newCard);
}
}
}