I am trying to create an event/date orginaizer in C++. The overview is like a calender show one month and every Day in this calender is an Object (type: EventCell) The class EventCell stores the events for his day in a vector (name: eventData with type: "EventInfo": class for storing day, name, start/endtime).
But when I switch the month I want to clear this vector, destroy all of its objects and free the momory of its variables. I tried this:
for (unsigned int i = 0; i < terminData.size(); i++)
{
delete terminData[i];
}
terminData.clear();
It calls the Deconstructor but the variables etc are still alive. If I make this for example:
terminData[0]->getDay();
result: 3
I still get the value of the Variable from the deleted object...
I think if I dont delete everything its probably gets to big, because every time I change the month, it is creating an object for every event.
Any suggestions how I could actually delete an object with its variable etc to get back the memory and create an new?