I'm trying to iterate through a Players hand of cards.
#include <vector>
#include <iostream>
class Card {
int card_colour, card_type;
public:
std::string display_card();
};
std::string Card::display_card(){
std::stringstream s_card_details;
s_card_details << "Colour: " << card_colour << "
";
s_card_details << "Type: " << card_type << "
";
return s_card_details.str();
}
int main()
{
std::vector<Card*>current_cards;
vector<Card*>::iterator iter;
for(iter = current_cards.begin(); iter != current_cards.end(); iter++)
{
std::cout << iter->display_card() << std::endl;
}
}
This line
std::cout << iter->display_card() << std::endl;
currently comes up with the
error: Expression must have pointer-to-class type.
How can I fix this?
See Question&Answers more detail:os