Child Packages for Generic Packages
Requirements
- The child of a generic package must itself be generic
- A generic child must be instantiated
- A generic child is instantiated using the instance of the parent package
Example 1
- Let's create a child package that contains
a function that returns the size of a stack.
- This generic child does not have any parameters.
- The generic child in the next example does have parameters.
Example 2
- Now let's create a child package with these operations
-
function size(s: Stack) return Integer
(as above)
-
procedure print_stack(s: Stack)
(for printing the stack)
- What is required to print a stack?
- Let's see: