Link* norse_gods = new Link("Thor", nullptr, nullptr);
// norse gods points to an instance of Link.
norse_gods = new Link("Odin", nullptr, nullptr);
// norse_gods points to a new instance of a Link object. The previous object is no
// no longer reachable. This is what we call a memory leak.
norse_gods -> succ -> prev = norse_gods;
// object pointed to by norse_gods refers to itself via it's prev/succ pointers.
norse_gods = new Link("Freia", nullptr, nullptr);
// norse_gods points to a new instance of a Link object. The previous object is no
// no longer reachable. This is what we call a memory leak.
norse_gods -> succ -> prev = norse_gods;
// object pointed to by norse_gods refers to itself via it's prev/succ pointers.
Link* norse_gods = new Link("Thor", nullptr, nullptr);
// norse_gods points to a Link object.
norse_gods = new Link("Odin", nullptr, norse_gods);
// norse_gods points to a new Link object. The new object's succ pointer points to the
// old Link object.
norse_gods -> succ -> prev = norse_gods;
// The new Link's succ and prev pointers point to itself. The old Link object is unreachable.
// you have a memory leak.
norse_gods = new Link("Freia", nullptr, norse_gods);
// norse_gods points to a new Link object. The new object's succ pointer points to the
// old Link object.
norse_gods -> succ -> prev = norse_gods;
// The new Link's succ and prev pointers point to itself. The old Link object is unreachable.
// you have a memory leak.