#include #include using namespace std; using namespace boost; class Object { public: Object(string n) { name = n; cout << name << " Created!" << endl; } ~Object( ) { cout << name << " Destroyed!" << endl; } void setOther(shared_ptr o) { other = o; } string name; shared_ptr other; }; int main( ) { shared_ptr ptr1(new Object("A")); shared_ptr ptr2(new Object("B")); ptr1->setOther(ptr2); ptr2->setOther(ptr1); return 0; }