Which of the following is a valid destructor of the class name "Country"?

Options
- int ~Country()
- void Country()
- int ~Country(Country obj)
- ~Country()


CORRECT ANSWER : ~Country()

Discussion Board
C++ - Destructors

The correct answer is ~Country(). Destructor has the same name as the class prefixed with a tilde(~) sign. Destructor is a type of special member function of a class and. It is used to destroy the memory allocated by the constructor. It is called automatically by the compiler when the object goes out of scope.

Prajakta Pandit 01-25-2017 06:09 AM

No, all reponses are wrong!!

The constructor must not be signed with the "void"
The right response is Country(); just remove the "void"

Yves 07-13-2015 06:46 AM

destructor

destructor can defined for before datatype

d.janani 12-6-2014 04:33 AM

Comment

constructors and destructors do not have return types. It cannot be even void. The correct answer is missing.

manohar singh 01-30-2014 06:23 AM

Void

The destructor doesn't use "void".

Alexandre Thibodeau 12-15-2013 12:21 PM

Write your comments


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)


Advertisement