This would let you store different things of same type into one data structure, here its a list. A good and popular example would be file and folder hierarchical structure in your computer. Perhaps this is what this code demonstrates.
The code has two classes
Directory (derived from File).
Directory uses a
std::list to store pointer to Files. Since
Directory is inherited from
File the list could also store Directories. That's what the algo is. A
virtual function named
display() is called recursively to display them.