answersLogoWhite

0

Delete is a built-in operator used forcibly release a dynamically allocated resource. Delete can only be used on pointer types, including pointer arrays.

A destructor is a class method used to clean up any resources acquired by objects of the class. Destructors are invoked automatically from the most-derived class to the least-derived class, as soon as an object falls from scope.

When you delete a pointer to an object, the object's destructor sequence is invoked. Note that you must not delete named objects otherwise you end up with a null reference. References must never be null.

User Avatar

Wiki User

10y ago

What else can I help you with?

Continue Learning about Engineering

When is a destructor called?

Destructors are called when an object is no longer used. In a language like C++, this is done explicitly by the programmer when the delete operator is used on the object.


Does c language really supports destructors?

it doesnt support destructors


What is the Difference between virtual methods and non virtual methods in c sharp?

A function is a method that returns a value other than void. Methods includes functions, subroutines, constructors, destructors, and properties.


How do you describe the importance of destructors?

Destructors are used to free memory and release resources.


What does the delete operator do in addition to deallocation of memory space?

The delete operator calls the destructor of the object referenced by its operand. If the destructor is virtual, the destructor of each superclass up to the top of the inheritance hierarchy is also called, in order. If you don't define a destructor for a class, the compiler defines a default destructor that has no effect. Fundamental types (char, int, float, etc.) do not have destructors, so using delete has no other effects.As an aside: when you use inheritance, make sure to make your destructors virtual, so that objects are properly destroyed!Also note that you should not use C's free() on a pointer that you got from C++'s new, or use C++'s delete on a pointer you got from C's malloc(). These are not guaranteed to work, and mixing them might cause Big Bad Things to happen. In general, there is no reason to use malloc()/free() in C++ at all.

Related Questions

Difference between format and delete?

What is the difference between delete and format?


What is the difference between delete and delete sheet command?

delete command would delete selected word,line, paragraph or even sheet. Whereas delete sheet command would delete the whole sheet


What is difference between delete file in DOS and delete file in Windows?

i don't know the difference but what i know is ... deleted file from MS-DOS is never go to the recycle bin. Thanks !


When is a destructor called?

Destructors are called when an object is no longer used. In a language like C++, this is done explicitly by the programmer when the delete operator is used on the object.


Difference between the delete key an the back space?

The backspace key deletes to the left of the cursor, and the delete key deletes to the right of the cursor.


When was The Destructors - band - created?

The Destructors - band - was created in 1977.


Does c language really supports destructors?

it doesnt support destructors


What is the Difference between virtual methods and non virtual methods in c sharp?

A function is a method that returns a value other than void. Methods includes functions, subroutines, constructors, destructors, and properties.


How do you describe the importance of destructors?

Destructors are used to free memory and release resources.


What is the difference between backspace and delete key?

The delete key removes the character above or to the right of the cursor. The backspace removes the character to the left of the cursor.


What is the difference between pressing the Delete key or the left arrow key in the middle of a line of text?

Delete key deletes any amount of text. The left arrow key only moves the I beam


What are the ratings and certificates for The Destructors - 1968?

The Destructors - 1968 is rated/received certificates of: UK:A (original rating) (passed with cuts)