About 9,460,000 results
Open links in new tab
  1. 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 …

  2. 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 …

  3. C++ Constructor/Destructor inheritance - Stack Overflow

    For trivial cases that destructor just calls the base class' destructor, and often that means that there is no explicit code for its destructor (which imitates inheritance). But if a class has …

  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 …

  5. 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

  6. The difference between a destructor and 'delete' - Stack Overflow

    Jun 28, 2020 · A destructor is a special method for a class. It is called whenever an object goes out of scope, or someone calls it explicitly. An example where an objects destructor is called, …

  7. inheritance - What order are destructors called and member …

    Feb 6, 2015 · 25 Very similar question as these, except not exactly: What is the order in which the destructors and the constructors are called in C++ Order of member constructor and …

  8. How do I correctly clean up a Python object? - Stack Overflow

    Specifically, I need Python to call the destructor for me, because otherwise the code becomes quickly unmanageable, and I will surely forget an exit-point where a call to .close () should be.

  9. c++ - Destructor for Binary Search Tree - Stack Overflow

    Dec 9, 2015 · I am trying to write the destructor for my Binary Search Tree and I know how to recursively loop through the tree, but I do not know how to do that in the destructor so that …

  10. If you shouldn't throw exceptions in a destructor, how do you …

    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 …