I'm having trouble with a vector which contains objects of class type Card (a class I needed to write myself). While troubleshooting I found that the vector has the right number of Cards created in it when I call push_back, namely 52, at the end of the contructor. However when I call separate functions, in particular the one I'm trying to troubleshoot is shuffle(), the vectors size is zero. The program compiles fine. I've included a copy of my function definitions as well as my main function below.
DeckOfCards::DeckOfCards() {
srand( time(NULL) );
//vector<Card> deck; // <- comment this out
currentCard = 0;
for ( int i = 0; i < 4; i++ ) {
for ( int j = 0; j < 13; j++ )
deck.push_back( Card( j, i ) );
}
cout << "Deck size at end of constructor: " << deck.size() << endl;
cout << "Calling shuffle function in constructor.\n";
shuffle();
}