incrementiing const_iterator

G

Gernot Frisch

void Class::work() const
{
for(const std::list<int>::const_iterator i = m_pts.begin();
i!=m_pts.end(); ++i);
}

cannot find binary operator ++ that accepts left side type of const
std::list<_Ty>::const_iterator

And ideas?


--
-Gernot
int main(int argc, char** argv) {printf
("%silto%c%cf%cgl%ssic%ccom%c", "ma", 58, 'g', 64, "ba", 46, 10);}

________________________________________
Looking for a good game? Do it yourself!
GLBasic - you can do
www.GLBasic.com
 
S

Sharad Kala

Gernot Frisch said:
void Class::work() const
{
for(const std::list<int>::const_iterator i = m_pts.begin();

Why const std::list<int>::const_iterator i ? You can't mutate const
objects, right ?

Sharad
 
J

John Harrison

Gernot Frisch said:
void Class::work() const
{
for(const std::list<int>::const_iterator i = m_pts.begin();
i!=m_pts.end(); ++i);
}

cannot find binary operator ++ that accepts left side type of const
std::list<_Ty>::const_iterator

And ideas?

Yes, lose the const.

for(std::list<int>::const_iterator i = m_pts.begin(); i!=m_pts.end();
++i);

Anything declared const cannot be incremented by definition.

john
 
G

Gernot Frisch

John Harrison said:
Yes, lose the const.

for(std::list<int>::const_iterator i = m_pts.begin();
i!=m_pts.end();
++i);

Anything declared const cannot be incremented by definition.

john

Doh! I tried:
const std::list<int>::itereator, then I saw that there's a
const_iterator and forgot to remove the 'const'. Thank you
 
M

Mike Wahler

Gernot Frisch said:
void Class::work() const
{
for(const std::list<int>::const_iterator i = m_pts.begin();

for(std::list<int>::const_iterator i = m_pts.begin();


-Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top