Why can't we declare destructor as private? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why can't we declare destructor as private?

why compiler giving error when destructor is declared as private?

21st Apr 2018, 7:00 PM
$¢𝐎₹𝔭!𝐨𝓝
$¢𝐎₹𝔭!𝐨𝓝 - avatar
1 Answer
+ 3
Because it's implicitly called outside the class when an objects memory is freed.
21st Apr 2018, 7:01 PM
Timon Paßlick