March 2000
Intermediate to advanced
576 pages
18h 13m
English
SizeOf Function
function SizeOf(const Value or type): Integer;The SizeOf
function returns the number of bytes
that Value
or
type occupies, which can be an expression
or a type identifier. SizeOf is not a real
function.
A common use for SizeOf is when calling
GetMem, so you know how much memory to
request.
The size of a pointer, object reference, or class reference is 4 because a pointer fits into 4 bytes (but future versions of Delphi might require more memory to store a pointer).
To learn the number of bytes an object takes up, call the
class’s InstanceSize method.
var
P: ^Integer;
begin
// Allocate memory for 32 integers.
GetMem(P, 32 * SizeOf(Integer)); /| GetMem Procedure, Length Function, TObject Type, Type Keyword |
Read now
Unlock full access