N
nabeel.girgis
I'm creating a deck class which uses a card class. The card class is
correct and works perfectly. One fo my member functions is to draw a
card, but I'm having trouble removing the top card after it has been
dealt. I have tested this in a seperate program to see if it work and
it does. But I get this error when I try to compile my deck class:
'std::_Vector_iterator<_Ty,_Alloc>
std::vector<_Ty>::erase(std::_Vector_iterator<_Ty,_Alloc>)' : cannot
convert parameter 1 from 'card' to 'std::_Vector_iterator<_Ty,_Alloc>'
1> with
1> [
1> _Ty=card,
1> _Alloc=std::allocator<card>
1> ] No user-defined-conversion operator available that can
perform this conversion, or the operator cannot be called.
This is my class declaration:
class deck1
{
public:
deck1();
bool isEmpty() const;
card draw_card();
void shuffle();
private:
vector<card> deck;
};
This is my draw_card function code.
card deck1::draw_card()
{
card top;
top = deck.at(0);
**** deck.erase(deck.begin());
return (top);
}
When I double click on the error, it brings me to the line with the
***. Thanks.
correct and works perfectly. One fo my member functions is to draw a
card, but I'm having trouble removing the top card after it has been
dealt. I have tested this in a seperate program to see if it work and
it does. But I get this error when I try to compile my deck class:
'std::_Vector_iterator<_Ty,_Alloc>
std::vector<_Ty>::erase(std::_Vector_iterator<_Ty,_Alloc>)' : cannot
convert parameter 1 from 'card' to 'std::_Vector_iterator<_Ty,_Alloc>'
1> with
1> [
1> _Ty=card,
1> _Alloc=std::allocator<card>
1> ] No user-defined-conversion operator available that can
perform this conversion, or the operator cannot be called.
This is my class declaration:
class deck1
{
public:
deck1();
bool isEmpty() const;
card draw_card();
void shuffle();
private:
vector<card> deck;
};
This is my draw_card function code.
card deck1::draw_card()
{
card top;
top = deck.at(0);
**** deck.erase(deck.begin());
return (top);
}
When I double click on the error, it brings me to the line with the
***. Thanks.