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.

有帮助吗?

解决方案

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;
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top