+ 2
Are there demerits of type casting ?
2 ответов
+ 14
Typecasting turns off your complier’s ability to check for type mismatches and therefore creates a hole in your defensive -programming armor. A program that requires many type casts probably has some architectural gaps that need to be revisited. Redesign if that’s possible; otherwise, try to avoid type casts as much as you can.
(Source: Code complete 2)
+ 4
Typecasting can not only get the program to overlook type errors, but can also result in loss of data and significant figures. Hence, it's best to avoid it if possible. Hope this helps! :)