So I dynamically allocated a class object with this code:
void Inventory::createNewInventoryItem(std::string itemName, unsigned int maxQuantity, unsigned int orderThreshold, double price)
{
InventoryItems* newItem = new InventoryItems;
newItem->createInventoryItem(itemName, maxQuantity, orderThreshold, price);
m_inventory.push_back(newItem);
}
Which is stored in this vector: std::vector<InventoryItems*> m_inventory;
Then once the object is done being used deleteInventoryItem is called, which is defined as:
void Inventory::deleteInventoryItem(int posInVector)
{
m_inventory.at(posInVector)->~InventoryItems();
m_inventory.erase(m_inventory.begin() + posInVector);
}
My question is: Will this deleteInventoryItem function successfully free up the memory used by the dynamic allocation in createNewInventoryItem? (This ties into my confusion around if delete[] is needed when a class deconstructor is called)
Sorry for the not "Mission critical" question, just trying to make sure I'm not continuing bad practices as I'm really trying to program as perfectly as I could...