4.13 Chapter 4 Summary

[ Table of Contents ] Prev ] Chapter Overview ] [ Glossary/Index ]

As usual, we begin with some self-test questions.  (Answers are listed below in reverse order.)

Self-Test Questions
Click Q#-# to see answer

Q4-1 What are some of Ada's built-in types and subtypes?
Q4-2 What are the complementary pairs of attributes applicable to enumeration types?
Q4-3 How many characters are in the Latin-1 set, and how are these related to the ASCII character set?
Q4-4 Why are subtypes useful?
Q4-5 What reserved words appear in the declaration of a fixed-point type?
Q4-6 What are the attributes that apply to constrained array types or to array objects?
Q4-7 If a record type has components: Name, Age, and DOB, how would client code that had created an object, My_Record, refer to the components separately?
Q4-8 What are the two steps of a private type declaration?
Q4-9 What are the two categories of access types?
Q4-10 What is a derived type?

Key points of this chapter

Self-Test Answers

A4-10 A derived type is one that inherits properties, such as components and primitive operations, from its parent type.
A4-9 Pool-specific access types, which designate objects dynamically created by an "allocator" and general access types, which can designate declared objects, dynamically created objects or subprograms.
A4-8 A private type is first partially declared in the visible part of a package declaration, and then fully declared in the private part of the same package declaration.
A4-7 The record components would be referred to as "My_Record.Name" or "My_Record.Age" or "My_Record.DOB".
A4-6 The attributes of constrained array types and array objects are 'Range, 'First, 'Last and 'Length.
A4-5 The reserved words type, is, delta and range appear in the declaration of a fixed-point type.
A4-4 Subtypes cause the compiler to insert run-time checks for out-of-range conditions, and they can make programs easier to read.
A4-3 There are 256 characters in the Latin-1 set (the same as the built-in set Character in Ada). The ASCII set consists of the first 128 characters of the Latin-1 set.
A4-2 'Image and 'Value return a string and a value, respectively.

'Pos and 'Val return a position number and a value, respectively.

A4-1 Built-in types: Boolean, Integer, Float, Character, Wide_Character, String, Wide_String.

Built-in suybtypes: Natural, Positive.

Click here to return to questions

Wrap-up Discussion

This chapter has covered Ada's built-in types and how to use them in creating user-defined types, along with illustrative examples, including the use of attributes and type conversions. Key terms included in the Glossary/Index are:

access type

array type attribute
box notation callback constrained array
declaration dereferencing derived type
discriminant enumeration type one-of-a-kind array
private type record type subtype
type type conversion unconstrained array

The next chapter focuses on the classification style of object oriented programming.

[ Back to top of pagePrev ] [ To next chapter ]