Which method is called automatically when an object is destroyed in C++ ?

2025

Which method is called automatically when an object is destroyed in C++ ?

  1. A.

    Destructor

  2. B.

    Constructor

  3. C.

    Finalize ()

  4. D.

    Cleanup()

Attempted by 43 students.

Show answer & explanation

Correct answer: A

The destructor is the special member function that gets called automatically when an object's lifetime ends. It performs cleanup tasks like releasing memory or closing files before the object is destroyed.

Explore the full course: Tpsc Assistant Technical Officer