Question

I'm looking at Marmalade's implementation of CSharedPtr, which purports to perform reference counting. The documentation states that:

When the last CSharedPtr<> referring to a particular object goes out of scope, the reference count reaches zero, and the the delete operator is called on the object.

Is there any way to release the object without it going out of scope? I don't seem to be able to set it to NULL.

Was it helpful?

Solution

Try constructing a new CSharedPtr using the constructor that lets you pass in a pointer and then assigning that to the one you want to set to null.

CSharedPtr<T> cNullPtr( NULL );
existingPtr = cNullPtr;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top