I have class called Entity that I have to dynamically create, so I store it in a vector called EntityList. I am trying to make it so that when I get a certain input, I can delete the entity and remove it from EntityList.
Entity:
1 2 3 4 5 6 7 8 9 10
class Entity
{
private:
//Data members
public:
Entity();
~Entity();
void Delete();
};
I didn't put anything in the deconstructor, should I?
Entity::~Entity() {}
void Entity::Delete() {deletethis;}
1 2 3 4 5
//Pseudo code
if (KeyPress = d)
{
EntityList[1].Delete();
}
When I try this, my program crashes with no error and the files I would have written to get corrupted.