Why destructor is called 3 time can u please explain? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why destructor is called 3 time can u please explain?

https://code.sololearn.com/cXcoRU80nRpQ/?ref=app

9th Jun 2023, 7:54 PM
Harsh Agrawal
Harsh Agrawal - avatar
1 Answer
+ 3
What's your expected output? When the code reaches return 0 in main() the program execution ends and the 3 objects you created are erased. The class destructor is called for each of them.
9th Jun 2023, 11:29 PM
Kevin ★