/* CSE 333 Su12 lecture 13 demo: weakcycle.cc */ /* Gribble/Perkins */ // Example of weak pointers to avoid cycles. #include #include using boost::shared_ptr; using boost::weak_ptr; class A { public: shared_ptr next; weak_ptr prev; }; int main(int argc, char **argv) { shared_ptr head(new A()); head->next = shared_ptr(new A()); head->next->prev = head; return 0; }