Czy C używa oceny zwarcia, nawet jeśli argumenty są wywołaniami funkcji?
Wiem, że operatory logiczne sprawdzają zwarcie. To znaczy, jeśli jest takie oświadczenieA && B && C
, a następnie, jeśliA
to fałsz,B
iC
nie są oceniane. Ale dotyczy to również przypadków, w którychB
iC
są wywołania funkcji?
Na przykład instrukcja return w tym kodzie:
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) );
}