>     I think I can use statement like this:
> 
>     1.      (*i).x+=1.0;
> 
>      or
> 
>     2.      MyObject& t=*i;
> 
>     But the g++ compiler always think "i" is a const_iterator,
> it give error for 1, and warning for 2.
> 
>     Who can tell me why?

If i is a const_iterator, the object referred-to by the iterator is
const, and you must not modify it. If the object is const, then (*i).x
is also const, and you cannot assign to it. Also, *i is of type
"MyObject const &"; you should not assign this to a variable of type
"MyObject&", as this also gives you a way to modify *i, even though *i
is const.

Regards,
Martin

Reply via email to