What is a destructor in C++?
19 views
- A function that is used to create objects of a class.
- A function that is used to destroy objects of a class. (Correct Answer)
- A function that is used to copy objects of a class.
- A function that is used to compare objects of a class.
Explanation
Correct answer: b) A function that is used to destroy objects of a class.
Explanation: A destructor in C++ is a special member function that is called when an object of a class is destroyed. It is used to free any resources that the object may have allocated during its lifetime.