473,378 Members | 1,110 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

incrementiing const_iterator

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
Jul 22 '05 #1
4 1545

"Gernot Frisch" <Me@Privacy.net> wrote in message
news:2q*************@uni-berlin.de...
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
Jul 22 '05 #2

"Gernot Frisch" <Me@Privacy.net> wrote in message
news:2q*************@uni-berlin.de...
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
Jul 22 '05 #3

"John Harrison" <jo*************@hotmail.com> schrieb im Newsbeitrag
news:2q*************@uni-berlin.de...

"Gernot Frisch" <Me@Privacy.net> wrote in message
news:2q*************@uni-berlin.de...
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


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
Jul 22 '05 #4

"Gernot Frisch" <Me@Privacy.net> wrote in message
news:2q*************@uni-berlin.de...
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
Jul 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: john smith | last post by:
Hi, I'm a little confused as to why the following code generates and error when compiling: #include <iostream> #include <vector> #include <iterator> using namespace std; void...
3
by: CoolPint | last post by:
If I were to design my own container and its iterators, I understand that I need to provide both "iterator" and "const_iterator" so that begin() and end() return appropriate ones depending on the...
5
by: John Harrison | last post by:
I there a reliable and generic method to convert a const_iterator to an iterator (i.e. something like const_cast). I ask because I'm writing some methods which take and return iterators. A const...
1
by: flopbucket | last post by:
Hi, For the learning experience, I am building a replacement for std::map. I built a templated red-black tree, etc., and all the basic stuff is working well. I implemented basic iterators and...
3
by: Bit byte | last post by:
whats the difference - apart from what the name suggests? - i.e. one is const What are there pros and cons of using one over the other ?
4
by: kotau | last post by:
Hi, I'm having trouble with something that would appear to have a simple solution. Here's a version of the code I'm working with: const Item* p 0; name::const_iterator i;
10
by: Yahooooooooo | last post by:
Hi, learning c++, can some one check below program. its giving compiler error. #include <iostream> #include <list> using namespace std; typedef list<intListInt;
2
by: subramanian100in | last post by:
Consider the code fragment: vector<intcontainer; container.push_back(0); container.push_back(1); container.push_back(2); Now I want to iterate through the 'container'. For this, instead...
2
by: Markus Dehmann | last post by:
I want to derive from std::set, like shown below. But when I try to declare an iterator over the contained elements I get an error, see the twp uncommented lines: #include <set> template<class...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.