C++: What is best way to destruct this code?
You mean to free resources.
In case of unordered_map
The way to do it right is not to do it. A unordered_map
will automatically release resources when it’s destroyed for anything allocated automatically.
Unless you allocated the values with new
, you don’t delete
them.
In case of linked list
~CacheFrame()
{
Node *temp = head->next, *temp2;
while(temp != NULL)
{
temp2 = temp;
temp = temp->next;
delete temp2;
}
}
2
solved C++: What is best way to destruct this code? [closed]