The error is that you try to get the addresses of two reference variables and compare them.
&p
is a memory location and
&q
is another memory location. This,
&p==&q
, always returns false except in the following case of using your == operator.
if(a == a)
. (
a
is an object of type
istream_iterator
).
If you want to compare the 2 integer variables (
p
and
q
), use the following instead of your line of code.
if(!p.eof && !q.eof)return p==q;