Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

STL List/Iterator problems with Visual C++

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
The following piece of code should compile:

using namespace std;
void test() {
list<int> l;
list<int>::iterator i;

i = l.begin();
while (i != l.end()) {
i++;
}
}

But it gives me the following errors:
error C2667: '!=' : none of 2 overload have a best conversion
error C2593: 'operator !=' is ambiguous

Is this some incompatibility between STL and Visual6?
How can it be solved?

Thanks in advance!
/Julien
 
Nothing wrong with the code. It should work in visual6. You should check the project settings.
 
I´ve, and I´ve checked options on the net.
I heard STLPort might fix it but I can´t figure out where to set the settings... I´m very new to Visual C++, I´ve only used Metrowerks CodeWarrior for MacOS before.
/Julien
 
a clean way is to use visual c++ 6 AppWizard to create a new &quot;win32 console application&quot; and put your STL code into the main() function then test it.
 
Seems to me that the compiler is finding multiple operator!=(). I would check through your source and see if you have a global operator!=() defined. Meaning, look for:

operator!=(const std::list<int>::iterator&, const std::list<int>::iterator&) const;

Note: <int> could be replaced by a template <> parameter in a definition that's floating out there.

Something of that variation. It looks like your compiler is finding multiple operator!=(). Two actually, if the compiler error you typed in is correct.

J
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top