So, I am trying to simply print the content of the vector that I am creating. Essentially I am trying to output the player which would be an int (i.e. 1-4) and the player's hand which consists of Card objects. So, for example, I am trying to get it to the point where newPlayerHand[1][1] will give me "Ace of Spades", and newPlayerHand[1][2] will output "Jack of Clubs"
void Blackjack::deal()
{
// create a new hand
vector < vector < Card >> newPlayerHand;
for (int i = 0; i < numPlayers; i++)
{
vector < Card > player; // Create an empty row
for (int j = 0; j < 2; j++) {
player.push_back(dealCard()); // Add an element(column)
// to the row
newPlayerHand.push_back(player); // Add the row to the main vector'
cout << newPlayerHand[i][j];
}
}
}
The above code looks and sounds correct logically to me, but it is giving me the error "No such operator <<" when I am attempting
cout << newPlayerHand[i];
Any advice or tips on where I am going wrong here would be greatly appreciated.
Ok, so I have edited it to account for the ostream operator, but I still seem to be getting an error for unresolved external. (basic_ostream)
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
copy(v.begin(), v.end(), std::ostream_iterator<T>(std::cout, " "));
return os;
}