#include "nsRefPtr.h" #include "myObject.h" int main() { nsRefPtrp1 = new myObject(); // create a new object of myObject nsRefPtr p2 = p1.get(); // get the object pointer p1->doSomething(); // call member function return 0; }
#include "nsRefPtr.h" #include "myObject.h" void someFunction() { nsRefPtrThis example shows how nsRefPtr automatically releases the object when it goes out of scope. Package library: Mozilla's Gecko Runtime Environment.p = new myObject(); // create a new object of myObject // Use p... } // p goes out of scope and the object is released automatically