Why is this comparison evaluating to true?

I'm working with linked lists and I am comparing the contents (chars) of two nodes within my linked list. I took a couple of screen shots that show the value of my variables and for some reason when I compare 'm' and 'i', my compiler tells me that 'm' is less than'i'.

Screen shot: http://imgur.com/ihynG

Why is this happening? My compiler is evaluating if(list1Tracer < list2Tracer) to true when it clearly is not. This doesn't happen anywhere else in my code and is really puzzling. Can anyone help me out?
Last edited on
For that comparison to work on the node item you need to overload operator< or use if(list1Tracer.item < list2Tracer.item)
+1 naraku9333

You are comparing pointers (addresses)

list1Tracer = 0x004E49A8
list2Tracer = 0x004E4A38

0x4E49A8 is less than 0x4E4A38.
Therefore list1Tracer is less than list2Tracer


The correct way to compare looks like it would be:
if(list1Tracer->item < list2Tracer->item)
Topic archived. No new replies allowed.