Can a class in c++ have multiple destructors? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

Can a class in c++ have multiple destructors?

10th Apr 2019, 6:55 PM
Narendra Kumar
Narendra Kumar - avatar
4 Answers
+ 9
No. Each class has only one destructor.
10th Apr 2019, 7:24 PM
Javier Felipe Toribio
Javier Felipe Toribio - avatar
+ 7
No , The class can has a many constructors , but only one destructor ; cause there is no meaning to a class has a many destrucors
10th Apr 2019, 7:33 PM
Zakaria Boudal
+ 7
Multiple constructors - yes; Multiple parents - unfortunately yes; Multiple destructors - no.
11th Apr 2019, 2:42 AM
Sonic
Sonic - avatar
+ 5
No, what would you like to do with it ? https://www.geeksforgeeks.org/destructors-c/ Can there be more than one destructor in a class? No, there can only one destructor in a class with classname preceded by ~, no parameters and no return type.
10th Apr 2019, 7:23 PM
sneeze
sneeze - avatar