May 2004
Intermediate to advanced
888 pages
22h 31m
English
Typecasting is a technique by which you can force the compiler to view a variable of one type as another type. Because of Delphi’s strongly-typed nature, you’ll find that the compiler is very picky about types matching up in the formal and actual parameters of a function call. Hence, you occasionally will be required to cast a variable of one type to a variable of another type to make the compiler happy. Suppose, for example, that you need to assign the value of a character to a Word variable:
var c: char; w: Word; begin c := 's'; w := c; // compiler complains on this line end.
In the following syntax, a typecast is required to convert c into a Word. In effect, a typecast tells the compiler that you really know ...
Read now
Unlock full access