comparing values

This is just a clarification question.... as im extreemly anal with fixing my work and making it neat and having no loose ends.

I just upgraded my software to microsoft visuals 2010 and i noticed when i try to compare values (using ==) it says that operator means nothing, did i mean =?

Is there a better way to compare variables? or am i on the right track?

As a side note... my program did build and its working for now... i just want to make shure i don't have any problems in the future.
Last edited on
comparing values has no effect unless you do something with the returned value.

VS would give you a warning if you do this:

a == b;

The reason you get the warning is because, whlie this DOES compare a and b, it doesn't do anything with the result of the comparison. You're telling the computer to compare the two, but you're never actually seeing whether or not they match.

On the other hand, the following would not produce a warning because they do something with the comparison:

1
2
3
bool compared =  a == b;  // comparison result stored in a variable for future use

if(a == b)  // comparison in a conditional statement 
Topic archived. No new replies allowed.