   more than one pointer point a object
  when I delete the object by one pointer. how about other pointer?I heard of smart pointer do the job. but it is not good to add smart pointer to a exist project.because shared pointer is seldom in the project.are there any simple way to solve the problem.   
  If you have two pointers to the same object and delete the object via one of them, you are left with two dangling pointers. The one you delete with should be reset to zero when you delete the object, by you. The other is completely dangling.I recommend using auto_ptr<>, available through:#include <memory>for 1 pointer to 1 object.Or boosts shared pointer:#include <boost/shared_ptr.hpp>Which manages multiple pointers pointing to one object.It is difficult to integrate smart pointers into large projects when the project is already well established because it requires a wide-spread syntax change. There is no way of bipassing the need to make this widespread change manually.Hope that helps,Dave   ;  Yes, I suggest too using somekind of smart pointer or auto pointer.If you feel that it is too much of trouble, then you can think some ways to get around it.- The object which creates a new object should also delete it.- Object about to be deleted should notify about its deletion so that other objects can check dependencies.- Try to make objects that handle their own existence (ie. objects are able to delete themselves but in the same time they still leave the system intact without needing help from outside).- In some cases, deletion of the objects isn't actually necessary / correct until some point. Let's say in a game, you toss a grenade which explodes. It sounds logical to delete this object, but consider case that you want to add a replay feature. So deleting the object isn't the correct answer but just placing the object to a invisible state or something like that. So, the since no game object gets ever deleted (until the game ends), there is nothing to worry about the object dependencies.- Use a simple reference count system. Every time a pointer is requested to the object it's reference count increases. You'll need a certain "Release" method which shall decrease the reference count. When the count reaches zero, the object can delete itself. This is the way that smarter pointers usually work.[Edited by - Demus79 on June 5, 2006 7:51:22 AM];Quote:Original post by Demus79Yes, I suggest too using somekind of smart pointer or auto pointer.If you feel that it is too much of trouble, then you can think some ways to get around it.- The object which creates a new object should also delete it.- Object about to be deleted should notify about its deletion so that other objects can check dependencies.- Try to make objects that handle their own existence (ie. objects are able to delete themselves but in the same time they still leave the system intact without needing help from outside).- In some cases, deletion of the objects isn't actually necessary / correct until some point. Let's say in a game, you toss a grenade which explodes. It sounds logical to delete this object, but consider case that you want to add a replay feature. So deleting the object isn't the correct answer but just placing the object to a invisible state or something like that. So, the since no game object gets ever deleted (until the game ends), there is nothing to worry about the object dependencies.- Use a simple reference count system. Every time a pointer is requested to the object it's reference count increases. You'll need a certain "Release" method which shall decrease the reference count. When the count reaches zero, the object can delete itself. This is the way that smarter pointers usually work.These kind of angels EXIST??? NO WAY??Dammit, why why, all those lines... All those hours...   