I understand what a double exclamation mark does (or I think I understand) but I am not sure how it is defined on a random object. For example in the code snippet below:
Assignment *a;
if (!getAssignment(query, a))
return false;
hasSolution = !!a;
if (!a)
return true;
How do I know what value will the double exclamation mark result in ? In other words does it always convert to true ? false ? or can you define a behavior for it such as executing a method to determine the result (how does the object know how to act in this situation) ? I am bit confused about this piece of code due to all these exclamation stuff going on.. Any explanation is appreciated.
Hope I was clear and thanks.
ais a pointer. In C++,nullptris defined to be an invalid pointer.!pointerturns anullptrpointer intotrueand a nonnullptrpointer intofalse.!booleanturnstrueintofalseandfalseintotrue. It will always work.!(!a)is a useful way to think of it.