문제

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