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

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -