Sometimes we want to explicitly force an object to be converted to a different type. For example, we might want to use floating-point division in the following code:
int i, j;double slope = i/j;
To do so, we’d need a way to explicitly convert
double. We use a cast to request an explicit conversion.
Although necessary at times, casts are inherently dangerous constructs.
A named cast has the following form:
where type is the target type of the conversion, and expression is the value to be cast. If type is a reference, then the result is an lvalue. The ...