I have a class Lobby which handles a list of Players(which is an Abstract Class, only pure virtual methods) now i tried to do the following:
...
std::list<Player*> list;
...
Lobby::Lobby (std::string name, unsigned int size){
m_size = size;
m_name = name;
std::list<Player*> list(size);
}
...
void Lobby::removePlayer(int playerID){
for (std::list<Player*>::iterator it = list.begin(); it != list.end(); it++){
if ((*it)->id == playerID){
it = list.erase(it);
}
}
}
...
I always get two erros, and have no glew how to solve them:
error C2259: 'Member' : cannot instantiate abstract
class
I am almost new in C++, but thought that if i use a list of pointers of the base class it should work?!
IntelliSense: no suitable user-defined conversion from "std::_List_iterator<std::_List_val<std::_List_simple_types<Member>>>" to "std::_List_iterator<std::_List_val<std::_List_simple_types<Member *>>>" exists**
Few points: first, to your problem. I can see nothing wrong with the code you provided, except thet it is not the code you are compiling. Looks like, you have a list of Members*, and you refer to it as Member. Second, Look at remove_if. it ill do the work for you. Last, looks like you have a memory leak here. you remove instance of player from the list, but do nor release it's memory (calling delete)