#include <boost/scoped_ptr.hpp> #include <stdlib.h> class MyClass { public: MyClass(int *p) : sptr_(p) { } private: boost::scoped_ptr<int> sptr_; }; int main(int argc, char **argv) { // initialize a scoped_ptr to contain an (int *) boost::scoped_ptr<int> x(new int(10)); // mc's constructor initializes the scoped_ptr in the sptr_ member // variable to contain sevenptr. int *sevenptr = new int(7); MyClass mc(sevenptr); return EXIT_SUCCESS; }