Re: [cpp] Re: 一个关于iterator的问题.
卢立璵(bad_fish)
luliyi1024 at gmail.com
Thu Apr 20 20:38:49 CST 2006
第二个 oprerator ++ (int) 中的 int 是一个哑元,表示这个 ++ 操作符是前置操作符;第一个是后置++操作符。
On 4/20/06, 张沈 鹏 (ZuRoc) <zsp747 at gmail.com> wrote:
> sorry, 打错了
> line_iterator operator++(int){
> line_iterator tmp=*this;
> read();
> return tmp;//不是*tmp
> }
> 2006/4/20, 张沈 鹏 (ZuRoc) <zsp747 at gmail.com>:
> > 读<泛型编程与stl>(作者:Matthew H. Austern)看到1.1有这样一个示例
> > class line_iteratot //可以从istream一次读入一行
> > {
> > ................................
> > public:
> > typedef input_iterator_tag iterator_category;
> > ................................
> > line_iterator operator++(){
> > read();
> > return *this;
> > }
> > line_iterator operator++(int){
> > line_iterator tmp=*this;
> > read();
> > return *tmp;
> > }
> > ...............................
> > };
> > 想请教一下operator++的第二个重载有什么用?
> > 谢谢.
> >
> >
> > --
> > I am an earth-man.
> >
>
>
> --
> I am an earth-man.
>
>
>
> _______________________________________________
> Cpp mailing list
> Cpp at codingnow.com
> http://codingnow.com/mailman/listinfo/cpp
>
>
More information about the Cpp
mailing list