From: Bhushan Kakulte on
While compiling .cc file i got following error

p2p/p2pjxta.cc:41: error: conversion from 'int' to non-scalar type
'std::_List_iterator<Neighbor*>' requested
p2p/p2pjxta.cc:42: error: conversion from 'int' to non-scalar type
'std::_List_iterator<Neighbor*>' requested
p2p/p2pjxta.cc:43: error: conversion from 'int' to non-scalar type
'std::_List_iterator<Neighbor*>' requested

original code is:

list<Neighbor*>::iterator neigh = NULL;
list<Neighbor*>::iterator lowerNeigh = NULL;
list<Neighbor*>::iterator upperNeigh = NULL;

Also I am facing error

p2p/p2pjxta.cc:59: error: no match for 'operator!=' in 'neigh != 0'
/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/
bits/stl_list.h:173: note: candidates are: bool
std::_List_iterator<_Tp>::operator!=(const std::_List_iterator<_Tp>&)
const [with _Tp = Neighbor*]
p2p/p2pjxta.cc: In member function 'bool
P2PJxtaApp::jxtaLookup(P2PAppData*)':

for original code

if (neigh != NULL)

Please help me out.....
Thanks


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Nick Hounsome on
On 20 July, 15:00, Bhushan Kakulte <b.kaku...(a)gmail.com> wrote:
> While compiling .cc file i got following error
>
> p2p/p2pjxta.cc:41: error: conversion from 'int' to non-scalar type
> 'std::_List_iterator<Neighbor*>' requested
> p2p/p2pjxta.cc:42: error: conversion from 'int' to non-scalar type
> 'std::_List_iterator<Neighbor*>' requested
> p2p/p2pjxta.cc:43: error: conversion from 'int' to non-scalar type
> 'std::_List_iterator<Neighbor*>' requested
>
> original code is:
>
> list<Neighbor*>::iterator neigh = NULL;
> list<Neighbor*>::iterator lowerNeigh = NULL;
> list<Neighbor*>::iterator upperNeigh = NULL;

You're not getting iterators at all.

a list iterator isn't a pointer (at least not so that you can see and
certainly not Neighbour* and since there is no such thing as a null
iterator there can be no meaningful comparison to nullptr or or int.

The closest you have to null is the result of end() or cend() on yout
list<Neighbour> and even then it is only valid for one list and only
whilst it isn't modofied


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Daniel Krügler on
On 20 Jul., 16:00, Bhushan Kakulte <b.kaku...(a)gmail.com> wrote:
> While compiling .cc file i got following error
>
> p2p/p2pjxta.cc:41: error: conversion from 'int' to non-scalar type
> 'std::_List_iterator<Neighbor*>' requested
> p2p/p2pjxta.cc:42: error: conversion from 'int' to non-scalar type
> 'std::_List_iterator<Neighbor*>' requested
> p2p/p2pjxta.cc:43: error: conversion from 'int' to non-scalar type
> 'std::_List_iterator<Neighbor*>' requested
>
> original code is:
>
> list<Neighbor*>::iterator neigh = NULL;
> list<Neighbor*>::iterator lowerNeigh = NULL;
> list<Neighbor*>::iterator upperNeigh = NULL;

The error message says it all: You cannot assign NULL to the specific
iterator. This is just normal, because list<Neighbor*>::iterator
satisfies
the requirements for an iterator. You mix mix up this with a pointer,
but iterators are generalizations of pointers and among the iterator
requirement does not exist a conversion from int. A reasoanble
initial value could be the end() iterator value (if you have a
container
nearby) which can be interpreted as "end-of-sequence".

> Also I am facing error
>
> p2p/p2pjxta.cc:59: error: no match for 'operator!=' in 'neigh != 0'
> /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/
> bits/stl_list.h:173: note: candidates are: bool
> std::_List_iterator<_Tp>::operator!=(const std::_List_iterator<_Tp>&)
> const [with _Tp = Neighbor*]
> p2p/p2pjxta.cc: In member function 'bool
> P2PJxtaApp::jxtaLookup(P2PAppData*)':
>
> for original code
>
> if (neigh != NULL)

Same problem: There does not exist a NULL state for iterators.
The most probable equivalent is to use the end() value of
a corresponding container.

HTH & Greetings from Bremen,

Daniel Kr�gler


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: red floyd on
On Jul 20, 7:00 am, Bhushan Kakulte <b.kaku...(a)gmail.com> wrote:
> While compiling .cc file i got following error
>
> p2p/p2pjxta.cc:41: error: conversion from 'int' to non-scalar type
> 'std::_List_iterator<Neighbor*>' requested
> p2p/p2pjxta.cc:42: error: conversion from 'int' to non-scalar type
> 'std::_List_iterator<Neighbor*>' requested
> p2p/p2pjxta.cc:43: error: conversion from 'int' to non-scalar type
> 'std::_List_iterator<Neighbor*>' requested
>
> original code is:
>
> list<Neighbor*>::iterator neigh = NULL;
> list<Neighbor*>::iterator lowerNeigh = NULL;
> list<Neighbor*>::iterator upperNeigh = NULL;
>
> Also I am facing error
>
> p2p/p2pjxta.cc:59: error: no match for 'operator!=' in 'neigh != 0'
> /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/
> bits/stl_list.h:173: note: candidates are: bool
> std::_List_iterator<_Tp>::operator!=(const std::_List_iterator<_Tp>&)
> const [with _Tp = Neighbor*]
> p2p/p2pjxta.cc: In member function 'bool
> P2PJxtaApp::jxtaLookup(P2PAppData*)':

Repeat after me: "An Iterator is not necessarily a pointer".

You can't assign an iterator to NULL. What are you actually trying
to accomplish?


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]