我有点过头了,我不确定这个错误意味着什么或该做些什么。这是我的代码:
class player::deck
{
public:
vector<int> deck;
int draw(){
int card = srand(time(NULL)) % deck.size();
deck.erase(deck(begin)+card);
return card;
}
};
我尝试做的是为每个玩家制作套牌。由整数表示的卡(0表示卡0,1表示卡1等)。
这是错误:
/home/ubuntu/workspace/try3/main.cpp: In member function ‘int player::deck::draw()’:
/home/ubuntu/workspace/try3/main.cpp:27:54: error: invalid operands of types ‘void’ and ‘std::vector<int>::size_type {aka long unsigned int}’ to binary ‘operator%’
int card = srand(time(NULL)) % deck.size();
^
/home/ubuntu/workspace/try3/main.cpp:28:34: error: no match for call to ‘(std::vector<int>) (<unresolved overloaded function type>)’
deck.erase(deck(begin)+card);
^
非常感谢任何帮助。如果我在错误的地方或我错误地使用该网站,请告诉我。