|
Re: [Dev-C++] (code correction) Help with vectors
From: Hossein Haeri <ultraprogman@em...> - 2004-02-29 12:18
|
Mike, As like as all of the recent messages I've posted to this list, sorry for this much late answer. I was too busy as this thread was going on, but I saved it till a time I can answer it, i.e. now! > You need to declare "it" as being of type iterator. So in the for > definition, you want: > > for (iterator it = myvec.begin(); it != myvec.end(); ++it) Although not wrong, but the principle of const-correctness tells us that "it" must be of type "cons_iterator" rather than just "iterator." > The iterator as assigned above is a pointer to the first element of the > vector. No, not necessarily! The types of vector<>::iterator, and vector<>::const_iterator are, as per the Standard, implementation-specific. That is, although they are most likely to be implemented using pure pointers, they are not needed to be so. In fact, they are some widely-used implementations of STL (such as STLPort) which do not implement the above stuff using pure pointers. Regards, --Hossein -- ___________________________________________________________ Sign-up for Ads Free at Mail.com http://promo.mail.com/adsfreejump.htm |
| Thread | Author | Date |
|---|---|---|
| Re: [Dev-C++] (code correction) Help with vectors | Hossein Haeri <ultraprogman@em...> |