From c9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c Mon Sep 17 00:00:00 2001 From: Martial Simon Date: Mon, 15 Sep 2025 01:08:27 +0200 Subject: add: graphs et rushs --- graphs/cpp/chain_of_responsibility/handler.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 graphs/cpp/chain_of_responsibility/handler.cc (limited to 'graphs/cpp/chain_of_responsibility/handler.cc') diff --git a/graphs/cpp/chain_of_responsibility/handler.cc b/graphs/cpp/chain_of_responsibility/handler.cc new file mode 100644 index 0000000..256933b --- /dev/null +++ b/graphs/cpp/chain_of_responsibility/handler.cc @@ -0,0 +1,19 @@ +#include "handler.hh" + +#include +Handler::Handler(Handler* next) + : next_{ next } +{} +void Handler::set_successor(Handler* h) +{ + next_ = h; +} +void Handler::forward_request(int level) +{ + if (next_ == nullptr) + { + std::cout << "Nobody can handle this request\n"; + } + else + next_->handle_request(level); +} \ No newline at end of file -- cgit v1.2.3