MyClass* ptr = new MyClass(); RefPtrrefPtr(ptr);
RefPtrrefPtr; refPtr.setObject(new MyClass());
RefPtrExamples Briefly Described: The first example creates an object of a class called MyClass and assigns it to a RefPtr. This ensures that the object will be properly deleted when the reference count reaches zero. The second example creates an empty RefPtr and later sets it to point to an object of MyClass. The third example sets a RefPtr to NULL, effectively destroying the object it was pointing to. Package/Library: The RefPtr class is not a part of the standard C++ library. It is a part of the OpenSceneGraph package/library, which is a 3D graphics toolkit for C++.refPtr; refPtr.setObject(NULL);