I am well aware of the advantage in using static_cast
rather than C-style casting for pointer types.
If the pointer types are incompatible, then:
static_cast
will yield a compile-time error at a specific line within the source code- C-style casting might lead to a runtime error at a "random" point in the execution of the program
But I am unable to find any similar example for non-pointer types.
In other words, both casting methods yield the same result for non-pointer types.
Is that correct, or have I missed anything?
If yes, is static_cast
used for non-pointer types only in order to maintain coding consistency?