Can I multiply an int with a boolean in C++?

This is technically fine, if a bit unclear.

The bool will be promoted to an int, so the result is well-defined. However, looking at that code I don’t instantly get the semantics you are trying to achieve.

I would simply write something like:

height = legendText->isEmpty() ? 0 : height;

This makes your intent far clearer.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)