/* CSE 333 Su12 lecture 13 demo: strongcycle.cc */ /* Gribble/Perkins */ // A weakness of reference counting: a data structure that contains a // cycle will have objects whose reference count is non-zero even if // the data is no longer being used. That prevents automatic deletion // of the data. #include using boost::shared_ptr; class A { public: shared_ptr next; shared_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; }