プレーヤー型の要素を格納する次のベクトルがあります。
std::vector<player> players;
次の関数を持つゲームと呼ばれるクラスで:
void game::removePlayer(string name) {
vector<player>::iterator begin = players.begin();
// find the player
while (begin != players.end()) {
if (begin->getName() == name) {
break;
}
++begin;
}
if (begin != players.end())
players.erase(begin);
}
次のエラーが表示されます。
1>------ Build started: Project: texas holdem, Configuration: Debug Win32 ------
1> game.cpp
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\xutility(2514): error C2582: 'operator =' function is unavailable in 'player'
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\xutility(2535) : see reference to function template instantiation '_OutIt std::_Move<_InIt,_OutIt>(_InIt,_InIt,_OutIt,std::_Nonscalar_ptr_iterator_tag)' being compiled
1> with
1> [
1> _OutIt=player *,
1> _InIt=player *
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(1170) : see reference to function template instantiation '_OutIt std::_Move<player*,player*>(_InIt,_InIt,_OutIt)' being compiled
1> with
1> [
1> _OutIt=player *,
1> _InIt=player *
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(1165) : while compiling class template member function 'std::_Vector_iterator<_Myvec> std::vector<_Ty>::erase(std::_Vector_const_iterator<_Myvec>)'
1> with
1> [
1> _Myvec=std::_Vector_val<player,std::allocator<player>>,
1> _Ty=player
1> ]
1> c:\vcprojects\texas holdem\texas holdem\game.h(29) : see reference to class template instantiation 'std::vector<_Ty>' being compiled
1> with
1> [
1> _Ty=player
1> ]
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
ラインの削除
players.erase(begin);
エラーを修正しますが、なぜそれが起こっているのですか、どうすれば修正できますか?