InnerClass

#include <atomic>
#include <functional>
class ParserBase {
  public:
   virtual void Process () = 0;
}; // class ParserBase

class Base {
  public:
   Base();
   void SetRuning(bool running){
     running_.store(running);
   }
   void Process() {}
  private:
    class InnerBase : public ParserBase {
     public:
       InnerBase() = delete;
       InnerBase(Base* runer) : runer_(runer) {}
       void Process() override { runer_->Process();}
     private:
       Base* runer_ = nullptr;    
    } inner_base_;
  private:
   std::atomic<bool> running_{false};
};  // class Base

Base::Base():inner_base_(this) {
  auto other_set_running_function = std::bind(&Base::SetRuning, this, std::placeholders::_1);
  ParserBase* parser = &inner_base_;
}

int main() {
  Base base;
  return 0;
}
posted @ 2021-01-04 15:07  cyssmile  阅读(74)  评论(0编辑  收藏  举报