This problem could be solved using the composite pattern or a variation of the pattern. This design pattern composes objects into tree hierarchies and enables treating groups (or trees) of objects the same way as individual objects of the same type. The following class diagram shows a hierarchy of classes that can be used for generating passwords:
password_generator is the base class and has several virtual methods: generate() returns a new random string, length() specifies the length of the strings it generates, allowed_chars() returns a string with all the characters it uses for generating passwords, and ...