conditional operator in c++ -
this question has reply here:
what '?' in c++? 7 answersi confused next codes , seek understand mean.
if( (root->left == null) || (root->right == null) ) { node *temp = root->left ? root->left : root->right; } it means if root->left ==null temp = root->left? else temp = root->right?
you not right, u idea. conditional operator takes 3 operands.
var = status ? expression1 : expression2 is equivalent
if( status ) var = expression1 else var = expression2 in case means
if root->left != null temp = root->left, else temp = root->right
instead of
if root->left ==null temp = root->left, else temp = root->right
c++
No comments:
Post a Comment