Searching for "destructor"

Q:

What is Constructors and Destructors?

Answer

CONSTRUCTOR : PHP allows developers to declare constructor methods for classes. Classes which have a constructor method call this method on each newly-created object, so it is suitable for any initialization that the object may need before it is used.

DESTRUCTORS : PHP 5 introduces a destructor concept similar to that of other object-oriented languages, such as C++. The destructor method will be called as soon as all references to a particular object are removed or when the object is explicitly destroyed or in any order in shutdown sequence.

Report Error

View answer Workspace Report Error Discuss

Subject: PHP

Q:

How to handle error in the destructor?

A) throwing B) terminate
C) both a & b D) none of the mentioned
 
Answer & Explanation Answer: B) terminate

Explanation:

It will not throw an exception from the destructor but it will the process by using terminate() function.

Report Error

View Answer Report Error Discuss

Filed Under: C++

Q:

what is the use of virtual destructor in c++?

Answer

A destructor is automatically called when the object is destroyed. A virtual destructor in C++ is used primarily to prevent resource leaks by performing a clean-up of the object.

Report Error

View answer Workspace Report Error Discuss

Subject: C++