I am getting memory leak errors when running my program.. I have determined that the error is in this section, specifically in the push_back line for the vector. the newCard variable receives the pointer to the Card object just fine. The problem occurs when I try to push this pointer onto the vector. the vector is part of the class this funtion belongs to,a nd is defined as vector <Card*> guardiansHand. Any input or information would be appreciated. thanks!
Code:
for ( int x = 0; x < drawNumber; x++ )
{
Card* newCard = new Card;
cardIndex = ( rand( ) % theDeck->getDeckSize( ) + 1 );
cout << cardIndex << endl;
theDeck->findACard( cardIndex );
newCard = theDeck->findACard( cardIndex );
guardiansHand.push_back( newCard );
newCard->printCardInfo( );
}