Top "Destructor" questions

A special method in object-oriented programming which is invoked when an object is destroyed

Is there a destructor for Java?

Is there a destructor for Java? I don't seem to be able to find any documentation on this. If there …

java garbage-collection destructor
How do I correctly clean up a Python object?

class Package: def __init__(self): self.files = [] # ... def __del__(self): for file in self.files: os.unlink(file) __del__(self) …

python destructor
Does delete on a pointer to a subclass call the base class destructor?

I have an class A which uses a heap memory allocation for one of its fields. Class A is instantiated …

c++ memory-management destructor delete-operator base-class
Creating an object: with or without `new`

Possible Duplicate: What is difference between instantiating an object using new vs. without This is probably a basic question, and …

c++ constructor new-operator destructor
How to destroy an object?

As far as I know (which is very little) , there are two ways, given: $var = new object() Then: // Method 1: Set …

php object destructor destroy
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 …

c++ destructor
Dynamically allocating an array of objects

I have a class that contains a dynamically allocated array, say class A { int* myArray; A() { myArray = 0; } A(int size) { …

c++ memory-management pointers destructor copy-constructor
When should I create a destructor?

For example: public class Person { public Person() { } ~Person() { } } When should I manually create a destructor? When have you needed to …

c# destructor
throwing exceptions out of a destructor

Most people say never throw an exception out of a destructor - doing so results in undefined behavior. Stroustrup makes …

c++ exception destructor raii
How to force deletion of a python object?

I am curious about the details of __del__ in python, when and why it should be used and what it …

python constructor garbage-collection destructor reference-counting