int main()
{
  srand(time(0));
  Handler1 root;
  Handler2 two;
  Handler3 thr;
  root.add(&two);
  root.add(&thr);
  thr.setNext(&root);
  for (int i = 1; i < 10; i++)
  {
    root.handle(i);
    cout << '\n';
  }
}
Exemple #2
0
int main()
{
  srand(time(0));
  Handler1 root;
  Handler2 two;
  Handler3 thr;
  root.add(&two);
  root.add(&thr);
  thr.setNext(&root);
  string chain;
  string ext;
  cout << "Enter chain: " << endl;
  cin >> chain;
  for(int i=chain.length()-1;i>0;i--){
      if(chain[i] == '.'){
         ext = chain.substr(i+1,chain.length());
         break;
      }
  }
  root.handle(ext);
  cout << '\n';
}