#includeclass MyClass { public: MyClass() { std::cout << "MyClass object constructed." << std::endl; } ~MyClass() { std::cout << "MyClass object destroyed." << std::endl; } }; int main() { RefPtr ptr; ptr.Init(new MyClass()); // do something with ptr return 0; }
#includeIn this example, a RefPtr object named obj is initialized to point to a new instance of the MyObject class (from the "mylibrary" package) using the Init member function.#include "mylibrary.h" RefPtr obj; int main() { obj.Init(MyObject::create()); // do something with obj return 0; }