It is allowed (just do not use the object after that), but I wouldn't write such code on practice. I think that delete this
should appear only in functions that called release
or Release
and looks like: void release() { ref--; if (ref<1) delete this; }
.