#Why no user-declared destructor is so important?

7 messages · Page 1 of 1 (latest)

vast ledge
#

I can somehow understand point 1 and 2, but what does there is no user-declared destructor mean?

hollow violetBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

#

@vast ledge

Screenshots!

Your message appears to contain screenshots but no code. Please send code and error messages in text instead of screenshots if applicable!

tight gorge
#

Because in 99% of the cases if you need a destructor the implicit move constructor and assignment operator would do the wrong thing.

#

What destructors typically do is clean up some sort of resource that doesn't clean itself up, meaning that implicitly assigning said resource in a move constructor would also not work.

#

If your destructor merely prints that it was called so you can see better what is happening you're in the 1%. You can still default those special member functions.

glass nest
#

If you have a custom destructor, that means there is some handling of resources that the compiler cannot handle automatically. So it's best for the complier to assume at that point that it won't be able to manage the resources in a move operation either.