ssercpp12 / Homework

Homework result for 12 sser cpp
1 stars 8 forks source link

about hw3 #3

Closed yycsysu closed 11 years ago

yycsysu commented 11 years ago

while (f.GetNext()) { std::cout << counter++ << " "<< f.word() << std::endl; }

GetNext是要对当前位置current_wordpos 加1并判断,要是current_wordpos 初始为0下面就不能像举例一样输出第一个单词了,但是要是current_wordpos 初始为-1的话要是没用GetNext就会出错了。

zhchbin commented 11 years ago

Yeah. This is obvious. So GetNext must be called before word. Do you think that this API design isn't good enough? En, you are in the right place! However, these method is used for adding stuff to this class.

zhchbin commented 11 years ago

Also notice that in the file_interface.h line 27,

FileInterface() : current_word_pos_(-1) {}