c++ - Does "pointerVariable ==" mean something different from "pointerVariable="? -
for example:
node * curr; if(curr = null) vs
node * curr; if(curr == null) what each of these things mean?
yes, different.
the first example uses assignment operator (=) , assigns null tocurr, , value used condition if. since it's null, , null considered false when comes conditions, execution never enter block. bug , @ least gcc , clang emit warning it.
the second 1 uses comparison operator (==) compare curr null. if curr equal null, execution enter block. curr remains unchanged.
Comments
Post a Comment