iterator.h

来自「C++&datastructure书籍源码,以前外教提供现在与大家共享」· C头文件 代码 · 共 37 行

H
37
字号
#ifndef _ITERATOR_H
#define _ITERATOR_H

template <class Kind>
class IteratorRef
{
  public:
    virtual ~IteratorRef() {}
    virtual void Init() = 0;
    virtual bool HasMore() = 0;
    virtual void Next() = 0;
    virtual Kind& Current() = 0;
  
};

template <class Kind>
class Iterator
{
  public:
    Iterator(IteratorRef<Kind>* it);
    ~Iterator();
    void Init();
    bool HasMore();
    void Next();
    
    Kind& Current();
    
  private:
    Iterator(const Iterator<Kind>& it);
    const Iterator& operator = (const Iterator<Kind>& it);
    
    IteratorRef<Kind> * myIt;
};

#include "iterator.cpp"

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?