I'm trying to create a pool to manage the allocation and so on of little game objects that will die and reborn quickly.
For it I have created a Pool:
template <class T>
class Pool {
public:
T* obtain()
{
T* obj = 0;
if (_avaibles.size() > 0)
{
std::vector<T*>::iterator it = _avaibles.begin();
obj = *it;
_avaibles.erase(it);
}
else
obj = new T();
return obj;
}
void free(T* obj)
{
_avaibles.push_back(obj);
}
void clear()
{
std::vector<T*>::iterator it = _avaibles.begin();
while (it != _avaibles.end())
{
T act = *it;
delete act;
++it;
}
}
private:
std::vector<T*> _avaibles;
};
The problem is I'm getting unresolved external symbols. The pool is placed as a static member of a class:
static Pool<Ship> _shipPool;
Here is the error:
Error 16 error LNK2001: unresolved external symbol "private:
static class Pool<class Ship> Asdf::_shipPool"
(?_shipPool@Asdf@@0V?$Pool@VShip@@@@A) C:\-\Asdf.obj