Sign in to follow this  
ZMaster

Smart Pointer Design

Recommended Posts

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

Share this post


Link to post
Share on other sites
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? ;-)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this