This topic presents a high-level overview of Delphi data types.
A type is essentially a name for a kind of data. When you declare a variable you must specify its type, which determines the set of values the variable can hold and the operations that can be performed on it. Every expression returns data of a particular type, as does every function. Most functions and procedures require parameters of specific types.
The Delphi language is a 'strongly typed' language, which means that it distinguishes a variety of data types and does not always allow you to substitute one type for another. This is usually beneficial because it lets the compiler treat data intelligently and validate your code more thoroughly, preventing hard-to-diagnose runtime errors. When you need greater flexibility, however, there are mechanisms to circumvent strong typing. These include typecasting, pointers, Variants, Variant parts in records, and absolute addressing of variables.
There are several ways to categorize Delphi data types:
simple ordinal integer character Boolean enumerated subrange real string structured set array record file class class reference interface pointer procedural Variant type identifier
The standard function SizeOf operates on all variables and type identifiers. It returns an integer representing the amount of memory (in bytes) required to store data of the specified type. For example, SizeOf(Longint) returns 4, since a Longint variable uses four bytes of memory.
Type declarations are illustrated in the topics that follow. For general information about type declarations, see Declaring types.
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
|
What do you think about this topic? Send feedback!
|