Original Post
I''m trying to NULL out dangling pointers when I delete an object. Smart pointers seem to only address garbage collection when you''re careless with your pointers and lose all link to your object... But when you have several pointers referencing an object, and you delete the object, it would be nice to have all the pointers referencing that object to now reference NULL. The first solution I did was to set the object flagged to delete, have the lists that reference it autoupdate and NULL out their pointers before deleting and then deleting the object in a deletion process at the end of an update loop.
That sort of system is very inflexible and has many ways to cause problems on its own. I was thinking of keeping track of the pointers that were assigned a particular object, and upon deletion, in the object''s destructor, NULL out all those pointers. The problem with this is that if those pointers to pointers themselves are bad pointers, you''ll have yet another bad dangling pointer problem.
Is there a way to detect bad pointers in runtime? Thanks
-Marv