70. Approval system

The problem described can be expressed in a series of if … else if … else … endif statements. An object-oriented version of this idiom is the chain of responsibility design pattern. This pattern defines a chain of receiver objects that have the responsibility of either handling a request or passing it to the next receiver in the chain if one exists. The following class diagram shows a possible implementation of the pattern for this problem:

employee is a class that represents an employee in the company. An employee may have a direct manager that is set with a call to the set_direct_manager() method. Every employee has a ...

Get The Modern C++ Challenge now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.