+ 1
How to set weak pointer as nullptr
Hi Refer code below : I set member variable weak pointer of class for catA and catB. As soon as catB died, I just need to do reset on catB and weak pointer of catA is expired... Now catA is friend with catC... This time catC scope is not over so can't use reset but just want to unfriend .... Thought to do nullptr assignment to weak pointer inside unfriend method but it doesn't compile.. How to assign nullptr to weak pointer or is there a better alternative approach ? Feel free to ask for queries if any... I will appreciate your feedback to improve the implementation. https://code.sololearn.com/crLusXibyk4t/?ref=app
2 Respuestas
+ 2
You can still use frnd.reset() - it will just detach the weak pointer, leaving the catC alive.
0
Thank you 😊