I was making a text based game.
I had created a class Inventory, which contained objects that can be carried.
Now I want to create a Deque to add and remove objects of the type Inventory.
Now if I don't declare objects of Inventory, is it possible that I create an object in Inventory?
I am adding things like this:
1 2
|
deque<Inventory*> inven;
inven.push_back(new Inven);
|
Tell me is the=is the correct way?
The other problem is that I have a static variable that will tell the number of objects int he inventory.
Creating objects like I do above increased the object count (which is incremented in the Constructor).
But simply removing an object from the deque (using
pop_front &
pop_back) doesn't call the destructor (which decrements the number of objects in the Inventory).
So is there a proper way to do this properly?