Memory-unsafe programming languages like C++ present new challenges when working with pointer data in classes. This motivates an approach to safely delete data that I like to call cascade deleting.

The idea is that in node-pointer-based data structures, like linked lists, we can include a delete next (or delete head for head pointers) in the destructor to safely delete all members of a data structure. By doing so, when we call the destructor of one object, we delete the next objects in the structure, which continue and continue.

class Node {
	private:
		Node* next;
	public:
		Node() { next = nullptr; }
		Node(Node* n) { next = n; }
		~Node() { delete next; }
}

This is a memory-safe approach to implementing data structures, but it also (by necessity) requires a clean severing from the structure before we delete nodes in isolation.