Smart Pointer Design

Started by
1 comment, last by ZMaster 17 years, 10 months ago
Hi. I'm looking for a design of a special smart pointer implementation with C++. Either existing concepts or new ideas may be named. Unlike other garbage collected designs, this one should be forced to unload an object from memory by using the delete keyword. The 'smart' part of the pointer should then make all other pointer instances point to NULL instead of some invalid memory area: Assume an object O residing on the heap and three pointer instances P1, P2, P3, each pointing to O. A call to delete P3 should now make P1 and P2 point to NULL. Note that by default, they would still point to O, but the memory there has become invalid and might be overwritten soon, if not already. Any idea or suggestion would be great! Thanks in advance. ZMaster
Advertisement
a run of the mill weak pointer fits your description.

boost smart pointers:

http://www.boost.org/libs/smart_ptr/smart_ptr.htm

-me
Quote:Original post by Palidine
a run of the mill weak pointer fits your description.


Great. Thanks. This is exactly what I was looking for.
However, I would also like to understand the logic behind this approach. Can you describe this in an understandable way? ;-)

This topic is closed to new replies.

Advertisement