Item* itemMngr::createGold(int x, int y, int amount)
{
Item* generateditem = NULL;
generateditem = new Currency(x, y, amount);
if(generateditem != NULL)
{
itemVector.push_back(generateditem);
}
return generateditem;
}
Don't do this. Not like that. new will not return NULL. Ever*. It will throw an exception if it fails. Specifically, it will throw a std::bad_alloc exception. You should *At least it won't ever return NULL when called like that. You have to explicitly use nothrow if you want it to return NULL on an allocation failure instead of throw an exception.