1234567891011121314151617181920212223242526
#include <iostream> #include "boost/smart_ptr.hpp" using namespace std; class MyClass { public: void welcome(){cout << "hello world!" << endl;} ~MyClass() { cout << "destroyed" << endl; } }; typedef boost::shared_ptr<MyClass> myClassPtr; int main(int argc, char *argv[]) { myClassPtr ptr(new MyClass); ptr->welcome(); return 0; }