If, else, while, for and do are some of the keywords used in both languages and have almost the same meaning. These keywords are associated with a condition to be checked upon.
In C++ the result of the conditional test may return any integer value(negative, positive or zero). In Java the result of the test should be a boolean( true or false) value and anything else is not permitted( if you try you may get a compile time error). If C++ can return an integer for a conditional test then, how does the C++ compiler decide on which path to choose?
The answer is, in C++, any non-zero integer or pointer is considered to be "true", and the integer 0 is considered to be "false".
No comments:
Post a Comment