<div dir="ltr">Hi Chris,<br><div class="gmail_extra"><br><div class="gmail_quote">On 17 December 2015 at 20:43, Chris Cleeland <span dir="ltr"><<a href="mailto:chris.cleeland@gmail.com" target="_blank">chris.cleeland@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Thu, Dec 17, 2015 at 1:38 PM, Ian Bruntlett <span dir="ltr"><<a href="mailto:ian.bruntlett@gmail.com" target="_blank">ian.bruntlett@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><br><div><div class="gmail_extra">If a member function finishes the job and frees the resources, have that member function modify the object's member variables so the destructor can recognise that the resources have been freed and it doesn't need to do anything about those resources.<br><br></div><div class="gmail_extra">This approach is called RAII and see this page:-<br><a href="https://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization" target="_blank">https://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization</a></div></div></div></blockquote><div><br></div></span><div>"delete this" sounds more like Resource Suicide and not RAII.</div></div></div></div></blockquote>Yes, the original question was this:-<br>"In my code there are objects created, which delete themselves. They can do it in the constructor, or later in some function. This is ugly, and I'm getting some wierd behaviour, probably because of this bad design."<br><br></div>Then another question was brought up, which indicated resource suicide. I've got to go offline now so I can't help much more than I have done.<br><br></div><div class="gmail_extra">BW,<br><br><br></div><div class="gmail_extra">Ian<br></div><div class="gmail_extra"><br>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div>-- ACCU - Professionalism in programming - <a href="http://www.accu.org" target="_blank">http://www.accu.org</a><br></div>-- My writing - <a href="https://sites.google.com/site/ianbruntlett/" target="_blank">https://sites.google.com/site/ianbruntlett/</a><br><div>-- Free Software page - <a href="https://sites.google.com/site/ianbruntlett/home/free-software" target="_blank">https://sites.google.com/site/ianbruntlett/home/free-software</a><br></div><br> </div></div></div></div></div></div></div> </div></div>