June 2025
Intermediate to advanced
1093 pages
33h 24m
English
It is easy to explain type conversion for the previously introduced int, bool, double, and string and their relatives because there is not much to convert with these types yet. Later, however, this will become an extensive topic that I will return to multiple times. In the context of expressions, I will exemplify the conversion between int and bool to illustrate the concept.
You can convert an int to a bool by simply using the type name as a function:
int value = 10;bool yesNo = bool(value); // function notation for type conversion
Coming from C, there is another notation for this. It is still very popular, and you will see it often:
bool yesNo = (bool)value; // C notation for type conversion
There is yet a third variant ...
Read now
Unlock full access