|
From: Ioannis V. <no...@ho...> - 2002-10-22 04:41:42
|
=20
-----Original Message-----
From: dev...@li...
[mailto:dev...@li...] On Behalf Of J=F6rgen
Sent: Monday, October 21, 2002 7:08 PM
To: dev...@li...
Subject: [Dev-C++] STL list problem
Hello all,
=20
I get an errormessage when I compile and I can't figure out what the
problem is.
Here's the code
=20
#include <iostream>
#include <list>
=20
int main(int argc, char *argv[]){=20
using namespace std;
=20
list<int> initialWeightList;
for(int i=3D0; i<10; i++)
initialWeightList.push_back(i); =20
list<int>::iterator iter;
for(
iter =3D initialWeightList.begin();=20
iter < initialWeightList.end(); // <--- error ?!?!?!
iter++
){
cout << "Here i do something" << endl;
} =20
}
=20
and here's the errormessage
=20
12 D:\Programmering\IDE\Dev-Cpp\__Projects\Test\main.cpp
no match for `_List_iterator<int,int &,int *> & < _List_iterator<int,int
&,int *>'
The for-statement is split up so I can locate the error
Any ideas?
If I replace all list<int> by vector<int>, and include <vector>
ofcourse, it works just fine.
=20
Yes list doesn't support this kind of iterators. Use !=3D instead:
=20
for(
iter =3D initialWeightList.begin();=20
iter !=3D initialWeightList.end();
++iter
)
=20
=20
Ioannis
* Ioannis Vranos
* Programming pages: http://www.noicys.freeurl.com
<http://www.noicys.freeurl.com/>=20
* Alternative URL: http://run.to/noicys
|