thanks for pointing that out, i dont know exactly how a vector takes care of memory allocation/deallocation, but here is how i did it
std::vector<Weapon*> m_weapons;
void Add(Weapon *weapon)
{
weapon->PlaySound();
m_weapons.pushback(weapon);
}
then i to use the Add function for a knife for example i wound do
weaponMgr->Add(new Knife());
then i did no cleanup, if you could give me any tips on cleaning up the vector it would help
ps. i have a GarbageCollect function that will erase weapons that dont exist anymore
for(int i = 0; i < m_weapons.size(); i++)
{
if(m_weapons[i]->IsDead())
{
m_weapons.erase(m_weapons.begin() + i);
}
}
should this work for getting rid of the sounds ( that are in the weapon class )
or is there a different thing i should be doing to clean it up