C++ set null to all pointers when deleting an object via one of them -
i have object, , have many pointers referring it. in different places can deleted, once in 1 place deleted, other places should aware of deletion. should check if object not deleted, delete. there smart pointer can job?
std::shared_ptr can this, along std::weak_ptr
i let google syntax yourself, basically, object held shared_ptr deleted when last shared_ptr goes out of scope, , weak ptrs able detect , stop working.
Comments
Post a Comment