type Date is record Day : Integer range 1 .. 31; Month : Integer range 1 .. 12; Year : Integer range 1 .. 4000 := 1995; end record;
The record component `Year' has an example of an `initialization clause' - any object created with this type automatically has initial values given in initialization clauses.
Creating variables of a record type is done the same way as any other type. A record component is referenced by using the variable name, a period, and the name of the record component. For example, let's create a variable called Ada_Birthday, and set its values to December 10, 1815:
procedure Demo_Date is Ada_Birthday : Date; begin Ada_Birthday.Month := 12; Ada_Birthday.Day := 10; Ada_Birthday.Year := 1815; end Demo_Date;
type Complex is record Real_Part, Imaginary_Part : Float := 0.0; end record;
and you declared the following type:
X : Complex;
How would you set X's Real_Part to 1?
Go back to the previous section
Go up to the outline of lesson 6
David A. Wheeler (wheeler@ida.org)