add cpp version abstract factory pattern