2009/5/19 Wallace Wang <Wallace.Wang@xxxxxxxxxxxx>: > > Symptoms: > When allocating and deleting an object of a class that is exported from a DLL, you may find that the new operator in the EXE is called to allocate the memory but the delete operator in the DLL is called to delete the memory. Therefore, there is a new/delete mismatching problem, which may cause run-time errors. > > I don't like the idea to override the new/delete operators in all of my classes. It is a huge change and may require multiple inheritance. Any other suggestion? > If you only pass a shared_ptr out of the DLL, instead of a raw one, that shared_ptr keeps a pointer to the DLL's delete, so no matter where it ends up getting deleted the correct delete gets called. That has all sorts of other consequences, so YMMV. ~ Scott