Verwendet C die Kurzschlussauswertung, auch wenn Argumente Funktionsaufrufe sind?
Ich weiß, dass logische Operatoren Kurzschlussprüfungen durchführen. Das heißt, wenn es eine Aussage wie gibtA && B && C
, dann wennA
ist falsch,B
undC
werden nicht ausgewertet. Aber gilt das auch für Fälle, in denenB
undC
sind Funktionsaufrufe?
Zum Beispiel die return-Anweisung in diesem Code:
bool areIdentical(struct node * root1, struct node *root2)
{
/* base cases */
if(root1 == NULL && root2 == NULL)
return true;
if(root1 == NULL || root2 == NULL)
return false;
/* Check if the data of both roots is same and data of left and right
subtrees are also same */
return (root1->data == root2->data && //I am talking about this statement
areIdentical(root1->left, root2->left) &&
areIdentical(root1->right, root2->right) );
}