About 50 results
Open links in new tab
  1. c++ - When to use virtual destructors? - Stack Overflow

    Jan 20, 2009 · In most implementations, the call to the destructor will be resolved like any non-virtual code, meaning that the destructor of the base class will be called but not the one of the derived …

  2. c++ - When do we need to define destructors? - Stack Overflow

    When you need to do this, you must define the destructor to be virtual within the base class. Otherwise, your derived destructors won't get called, independent of whether they are defined or not, and …

  3. c# - When should I create a destructor? - Stack Overflow

    A destructor is then essentially an assurance that if the consumer of your object forgets to dispose it, the resource still gets cleaned up eventually. (Maybe.) If you make a destructor be extremely careful and …

  4. How do I call the class's destructor? - Stack Overflow

    The destructor is something that is automatically called when your object goes out of scope, that is, when the computer leaves the "curly braces" that you instantiated your object in. In this case, when …

  5. .net - What is the difference between using IDisposable vs a destructor ...

    A destructor should generally never be used. It is only run .net wants it to run. It will only run after a garbage collectoin cycle. It may never actually be run during the lifecycle of your application. For this …

  6. c++ - How to properly define destructor - Stack Overflow

    Aug 18, 2011 · 2 Memory on stack If there is no heap-allocated object inside your class, there is no need for you to explicitly define the destructor of your class. The compiler-generated one should handle …

  7. If you shouldn't throw exceptions in a destructor, how do you handle ...

    The destructor calls close () if the file has been opened but makes sure that any exceptions do not propagate out of the destructor. So if the user of a file object wants to do special handling for …

  8. Do I need to explicitly call the base virtual destructor?

    When overriding a class in C++ (with a virtual destructor) I am implementing the destructor again as virtual on the inheriting class, but do I need to call the base destructor? If so I imagine it's

  9. c++ - A destructor is usually not called explicitly. Why would one want ...

    The referenced post is about calling a destructor explicitly on a local variable, whose destructor is also called again implicitly at the end of its scope.

  10. c++ - What should be in a proper destructor? - Stack Overflow

    Jul 26, 2012 · I know a destructor is essentially a function that deallocates memory or does a "clean up" whenever you are done with it. My question is, what goes in a proper destructor? Let me show you …