|
From: <qa...@ho...> - 2002-10-21 16:10:31
|
Hello all,
I get an errormessage when I compile and I can't figure out what the=
problem is.
Here's the code
#include <iostream>
#include <list>
int main(int argc, char *argv[]){
list<int> initialWeightList;
for(int i=3D0; i<10; i++)
initialWeightList.push_back(i);
list<int>::iterator iter;
for(
iter =3D initialWeightList.begin();
iter < initialWeightList.end(); // <--- error ?!?!?!
iter++
){
cout << "Here i do something" << endl;
}
}
and here's the errormessage
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.
Regards
/J=F6rgen
|
|
From: <h.r...@gm...> - 2002-10-21 21:26:25
|
> Hello all,
>
> I get an errormessage when I compile and I can't figure out what the
> problem is.
> Here's the code
>
> #include <iostream>
> #include <list>
>
> int main(int argc, char *argv[]){
> list<int> initialWeightList;
> for(int i=0; i<10; i++)
> initialWeightList.push_back(i);
>
> list<int>::iterator iter;
> for(
> iter = initialWeightList.begin();
> iter < initialWeightList.end(); // <--- error ?!?!?!
> iter++
> ){
> cout << "Here i do something" << endl;
> }
> }
>
> and here's the errormessage
>
> 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.
>
> Regards
> /Jörgen
>
>
Hi,
This works (with mingw2.0.0-3):
#include <iostream>
#include <list>
using namespace std;
int main(int argc, char *argv[]){
list<int> initialWeightList;
for(int i=0; i<10; i++)
initialWeightList.push_back(i);
list<int>::iterator iter;
for(
iter = initialWeightList.begin();
iter != initialWeightList.end(); // <--- error ?!?!?!
iter++
){
cout << "Here i do something" << endl;
}
system("PAUSE");
}
I think it is wrong to compare two iterators with < because in a list the
items are anywhere in the memory and not in order (as in vector). Iterators are
like pointers. You can compare it with == or !=.
regards
Horst
--
+++ GMX - Mail, Messaging & more http://www.gmx.net +++
NEU: Mit GMX ins Internet. Rund um die Uhr für 1 ct/ Min. surfen!
|
|
From: <qa...@ho...> - 2002-10-21 21:49:49
|
Danke Horst.
Ich habe es nichts jetzt versuchts, aber sagen sie es fungiert, es fungiert=
:-)
That was my poor German, haven't spoken or read it since my early=
schooldays, like 15-20 years ago.
And heres what I said (I think) in english, because that's the official=
language of the list :-)
Thanx Horst
Haven't tried it yet, but if you say it works, it works.
/J=F6rgen
*********** REPLY SEPARATOR ***********
On 2002-10-21 at 23:26 h.r...@gm... wrote:
>> Hello all,
>>
>> I get an errormessage when I compile and I can't figure out what the
>> problem is.
>> Here's the code
>>
>> #include <iostream>
>> #include <list>
>>
>> int main(int argc, char *argv[]){
>> list<int> initialWeightList;
>> for(int i=3D0; i<10; i++)
>> initialWeightList.push_back(i);
>>
>> list<int>::iterator iter;
>> for(
>> iter =3D initialWeightList.begin();
>> iter < initialWeightList.end(); // <--- error ?!?!?!
>> iter++
>> ){
>> cout << "Here i do something" << endl;
>> }
>> }
>>
>> and here's the errormessage
>>
>> 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.
>>
>> Regards
>> /J=F6rgen
>>
>>
>Hi,
>This works (with mingw2.0.0-3):
>
>#include <iostream>
>#include <list>
>
>using namespace std;
>
>int main(int argc, char *argv[]){
> list<int> initialWeightList;
> for(int i=3D0; i<10; i++)
> initialWeightList.push_back(i);
>
> list<int>::iterator iter;
> for(
> iter =3D initialWeightList.begin();
> iter !=3D initialWeightList.end(); // <--- error ?!?!?!
> iter++
> ){
> cout << "Here i do something" << endl;
> }
>
> system("PAUSE");
>}
>
>I think it is wrong to compare two iterators with < because in a list the
>items are anywhere in the memory and not in order (as in vector).
>Iterators are
>like pointers. You can compare it with =3D=3D or !=3D.
>
>regards
>Horst
>
>--
>+++ GMX - Mail, Messaging & more http://www.gmx.net +++
>NEU: Mit GMX ins Internet. Rund um die Uhr f=FCr 1 ct/ Min. surfen!
>
>
>
>-------------------------------------------------------
>This sf.net emial is sponsored by: Influence the future
>of Java(TM) technology. Join the Java Community
>Process(SM) (JCP(SM)) program now.
>http://ad.doubleclick.net/clk;4699841;7576298;k?http://www.sun.com/javavote=
>_______________________________________________
>Dev-cpp-users mailing list
>Dev...@li...
>TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|
|
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
|