⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 worditer.h

📁 C++&datastructure书籍源码,以前外教提供现在与大家共享
💻 H
字号:
#ifndef _WORDSTREAMITERATOR_H#define _WORDSTREAMITERATOR_H// Owen Astrachan 7/3/95, modified 4/9/99//// class WordStreamIterator//// void Open(string name)//        -- initializes iterator to file specified by name//// void Init(), void Next(), bool HasMore()//        -- "standard" iterating functions (see below)//// usage: call Init(), before accessing Current()//        call Next() to move to  the next word in the stream//        call Current() to access the current word//        call HasMore() to determine if Current() is valid//// string Current()//        -- returns current string (see below)//// WordStreamIterator iter;// iter.Open("testfile.dat");// for(iter.Init(); iter.HasMore(); iter.Next())//    cout << iter.Current() << endl;////#include <string>#include <fstream>using namespace std;class WordStreamIterator{  public:    WordStreamIterator();    void Open(const string & name);   // bind stream to specific text file    void Init();                      // initialize iterator    string Current();                 // returns current word    bool HasMore();                   // true if more words    void Next();                      // advance to next word  private:    string myWord;                    // the current word    bool myMore;                      // true if more words    ifstream myInput;                 // the stream to read from};#endif

⌨️ 快捷键说明

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