#include // for EXIT_SUCCESS #include // for std::shared_ptr using std::shared_ptr; struct N { shared_ptr next; shared_ptr prev; }; int main(int argc, char* argv[]) { shared_ptr head(new N()); head->next = shared_ptr(new N()); head->next->prev = head; return EXIT_SUCCESS; }