Basic types
Most of D's basic data types will be familiar to C-family programmers. In this section, we're first going to look at what the basic data types are. Then we'll discuss a couple of features that are related not only to the basic types, but to all types.
The types
First up, D includes the special type void
to mean no type. There is no such thing as a variable of type void
. As in C, void
is used to indicate that a function does not return a value. void
pointers can be declared to represent pointers to any type.
Instances of the bool
type are guaranteed to be eight bits in size and can hold one of two possible values: true
and false
. In any expression that expects a Boolean value, any zero value is converted to false
and non-zero is converted to true
. Conversely, in any expression that expects a numeric type, false
and true
are converted to 0
and 1
. Variables of type bool
are initialized to false
by default.
D supports signed and unsigned versions of integral types in 8-, 16-, 32-, and...