Why can't I use a "break" statement inside a ternary conditional statement in C++?

The ternary conditional operator is an operator that combines multiple expressions into a larger expression. break is a statement and not an expression, so it can't be used inside a ternary conditional expression.

You could, though, rewrite your code like this:

while (current->left != nullptr) current = current->left;

Hope this helps!


Why can't I use a “break” statement inside a ternary conditional statement in C++?

Because the ternary operator isn't a statement at all, it's an operator, and it is composed of expressions, not statements. break is a statement, not an expression.