On 11 Jan 2000, Aaron M. Ucko wrote:
> Fenglou Mao <[EMAIL PROTECTED]> writes:
>
> > I want to use an interator of this type:
> >
> > set<MyObject, lt<MyObject> >::iterator 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?
>
> set is an _associative container_, which means that it arranges
> elements according to the given comparison functor for efficient
> acces. If you modify elements in place, you might cause them to be
> disarranged, which may cause elements to be lost or even lead to other
> problems.
>
How can I modify an element? copy it out, modify it, erase old one,
insert the new one? It is really an ugly way, and I think the
abstract data-structure "set" don't require programmer to know so
much about the details.
Sincerely Yours,
FengLou Mao
*******************************
ADD:Mr. FengLou Mao
Institute of Physical Chemistry
Peking University
BeiJing
P.R.China
Tel:86-10-62756833
Fax:86-10-62751725