Structures
Structure is a composite data object. It is composed of fields that can have
different types.
struct RgbColor {
unsigned byte Red;
unsigned byte Green;
unsigned byte Blue;
};
The above definition introduces a type RgbColor, which can be
mapped to data or used in other definitions.
For example, you can use the RgbColor type to define an array of pixels:
struct ScreenArea {
unsigned dword nPixels;
RgbColor Area[nPixels];
};
Anonymous Structures
You don't need to declare a structure type if you need it only as a part of
another definition. For instance, you can skip a declaration of the RgbColor
type if it is used only within the ScreenArea definition:
struct ScreenArea {
unsigned dword nPixels;
struct {
unsigned byte Red;
unsigned byte Green;
unsigned byte Blue;
} Area[nPixels];
};
Anonymous structure definition looks exactly as the structured type definition
except there is no identifier following the struct keyword. Anonymous
definition may occur only within another definition and is allowed wherever
a type name is expected.
|