Frage

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.

War es hilfreich?

Lösung

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;
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top