Compiler doesn't recognize any of destructor operators in this code. Why? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

Compiler doesn't recognize any of destructor operators in this code. Why?

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

14th Apr 2017, 2:19 AM
Gigi
Gigi - avatar
2 Answers
+ 6
@Squidy thank you very much....my bad, I haven't even noticed it
14th Apr 2017, 2:42 AM
Gigi
Gigi - avatar
+ 5
It's because your bracketing is weird. You've got your destructors inside of the attack functions. Adjust your bracketing so that they're on the outside, as their own functions. E.g.: void attack() { cout << "Ninja!"<<endl; /* ~Ninja(){cout<<"Ninja dtor"<<endl;} */ } Should be void attack() { cout << "Ninja!"<<endl; } ~Ninja(){cout<<"Ninja dtor"<<endl;}
14th Apr 2017, 2:39 AM
Squidy
Squidy - avatar