Which of the following functions should be the destructor function for user…

2022

Which of the following functions should be the destructor function for user defined class Person in C++?

  1. A.

    Person(string s)

  2. B.

    Person()

  3. C.

    ~Person(string s)

  4. D.

    ~Person()

Attempted by 153 students.

Show answer & explanation

Correct answer: D

In C++, a destructor must be named with the class name preceded by a tilde symbol and cannot accept parameters. Option 3 correctly defines ~Person() which strictly adheres to this specific syntax requirement for user-defined classes.

Explore the full course: Uppsc Polytechnic Lecturer 2025 Cs