If an "if" is used in the following way what does it do?
Code:if(variable_name) { // What to do. }
If an "if" is used in the following way what does it do?
Code:if(variable_name) { // What to do. }
variable_name is converted to bool, and then the check for true/false happens.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
So it looks if the variable is set?
No. It converts the variable to type bool. What exactly that means depends on the type of the variable, and its value, e.g., a null pointer is converted to false, but a non-null pointer is converted to true.Originally Posted by Kitt3n
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)