Should objects delete themselves in C++?

You have made Update a virtual function, suggesting that derived classes may override the implementation of Update. This introduces two big risks. 1.) An overridden implementation may remember to do a World.Remove, but may forget the delete this. The memory is leaked. 2.) The overridden implementation calls the base-class Update, which does a delete this, … Read more

Self deletable application in C# in one executable

If you use Process.Start you can pass in the Del parameter and the path to the application you wish to delete. ProcessStartInfo Info=new ProcessStartInfo(); Info.Arguments=”/C choice /C Y /N /D Y /T 3 & Del “+ Application.ExecutablePath; Info.WindowStyle=ProcessWindowStyle.Hidden; Info.CreateNoWindow=true; Info.FileName=”cmd.exe”; Process.Start(Info); Code snippet taken from this article