Line 8 is incorrect! You should NEVER delete something you didn't allocate with new.
The destructors of those other objects will be called automatically just as their constructors were called automatically. Also you don't call the destructors explicitly unless you used placement new.
If you allocate memory for directory * parent in your constructor then yes you need to free/delete in your deconstructor. As a side note, I tend to er on the side of safety and check my pointers before deleting them, this will save you headache in the future...
e.g.
1 2
if(*pos)
delete (*pos);
And to clarify, standard containers will automatically call the deconstructor, but it will not deallocate memory that was allocated for that object so you do need to free that memory like you have.
As L B said, line 8 is incorrect. files is just a std::set which will cleanup itself.
Lets say your set was this instead:
1 2 3
//...
std::set<file> * files;
Your deconstructor would look something like this...
1 2 3 4 5 6 7 8 9 10 11
//...
//... No loop, deconstructors for each file object called automatically...
//...
if(files)
{
delete (files);
files = NULL;
}
//...