A function that is called automatically each time an object is destroyed is a A. constructor B. destructor C. destroyer D. terminator

[amp_mcq option1=”constructor” option2=”destructor” option3=”destroyer” option4=”terminator” correct=”option2″]

The correct answer is B. destructor.

A destructor is a special function that is called automatically when an object is destroyed. It is used to clean up any resources that the object may have allocated, such as memory or files.

A constructor is a special function that is called automatically when an object is created. It is used to initialize the object’s data members.

A destroyer is not a valid option.

A terminator is not a valid option.