c++ - Is calling non-member function from destructor OK? -


in c++, ok call non-member function (either free function or member of other objects) within destructor? calling (non-virtual, although in case shouldn't matter) method of object of different class. method crashes on trying access members.

on other hand, if different object child of destructed object (qt), matter?

in general destructor can call function needs destroy object. however, there couple of caveats:

  1. if function called destructor throws exception, exception must caught , handled in destructor.

  2. the function called destructor must not unconditionally create , destroy objects of type destructor belongs (since result in infinite recursion).


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -