Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Usage of "this" in destructor

Is it valid to call some function in destructor with this argument? Function does not store pointer, but assume full-functional object.

like image 864
KAction Avatar asked Jun 11 '12 11:06

KAction


1 Answers

this is still valid in the destructor.

However, you need bear in mind that virtual functions no longer work properly as you might expect once the object is being destroyed; see e.g. Never Call Virtual Functions during Construction or Destruction. Essentially, the dynamic type of the object is modified as each destructor completes.

like image 196
Oliver Charlesworth Avatar answered Oct 19 '22 17:10

Oliver Charlesworth