责任链模式的核心是解决一组服务中的先后执行处理关系。
#pragma once #include#include class Auth { public: virtual void setSuperior(Auth* superior) = 0; virtual void handleRequest(double amount) = 0; }; class Level1Auth : public Auth { public: Level1Auth(double ma, std::string n):maxAmount(ma),name(n),sup(nullptr){} void setSuperior(Auth* superior) { this->sup = superior; } void handleRequest(double amount) { if (amount <= maxAmount) return; else { if (this->sup != nullptr) { this->sup->handleRequest(amount); return; } } } private: double maxAmount; std::string name; Auth* sup; }; class GroupLeader : public Level1Auth { public: explicit GroupLeader(std::string name) :Level1Auth(100,name){} }; class Manager : public Level1Auth { public: explicit



