   Best way to have object pointed from several places safely?
  Hi!Could you consider the situation where you got object wich is beein managed from couple sources and if the first pointer gets deleted the second one should point to zero so it wont be used any more.This problem in c++ code:   COBJECT obj;COBJECT* p1 = &objCOBJECT* p2 = &obj// first pointer get''s deleted and so should the second one (actualy it should just get the zero "p2=0")// but even it could be done in this sample I dont know how to "inform" about this delete when p1 and p2 are "seperate" (hopefully you know what I mean?).delete p1;Is this a job for a smart pointer or what ever, becose I have only heard of that? 
Make a class that contains a void pointer, this points to your data, then have a list of pointers to pointers of this class. (i think this is called a smart pointer)Anyways, you would have a deconstructor in this class, that first will delete the object it points too, then it will go through every pointer in the list and set them to zero, then it will be deleted itself.You will also need a Addrefrence or soemthing function. You pass it a pointer to a pointer, and it sents the pointer to point to itself and adds it to the list.I think you may just want to search for smart pointers. ;quote:Original post by honayboyz  Make a class that contains a void pointer,.. thus totaly rendering useless the type system.Smart pointers could be very well what you are after, althought they dont use a pointer to void, they are generaly templated and thus have a pointer to the type you are pointing to.boost::shared_ptr is a good refence counting pointer, and sounds pretty much like what you need 