110k views
1 vote
The destructor automatically executes when the class object goes out of ____.

A.
scope

B.
use

C.
phase

User Zubin
by
6.6k points

1 Answer

3 votes

Answer:

scope

Step-by-step explanation:

Destructor is a member function and it call automatically when the class object goes out of scope.

Out of scope means, the program exit, function end etc.

Destructor name must be same as class name and it has no return type.

syntax:

~class_name() { };

For example:

class xyz{

xyz(){

print(constructor);

}

~xyz(){

print(destructor);

}

}

int main(){

xyz num;

}//end program

when the object is create the constructor will called and when the program end destructor will call automatically.

User Zskdan
by
6.4k points