Next: , Previous: 8.3, Up: 8.3


8.3.1 Overriding Indicators

1/2
An overriding_indicator is used to declare that an operation is intended to override (or not override) an inherited operation.

Syntax

2/2

overriding_indicator::= [not] overriding
Legality Rules

3/2
If an abstract_subprogram_declaration (see 3.9.3), null_procedure_declaration (see 6.7), subprogram_body, subprogram_body_stub (see 10.1.3), subprogram_renaming_declaration (see 8.5.4), generic_instantiation (see 12.3) of a subprogram, or subprogram_declaration (see 6.1) other than a protected subprogram has an overriding_indicator (see 8.3.1), then:

4/2

5/2

6/2

7/2
In addition to the places where Legality Rules normally apply, these rules also apply in the private part of an instance of a generic unit.

     NOTES

8/2

 Rules for overriding_indicators of task and protected entries and of protected subprograms are found in 9.5.2 and 9.4, respectively.
Examples

9/2
The use of overriding_indicators allows the detection of errors at compile−time that otherwise might not be detected at all. For instance, we might declare a security queue derived from the Queue interface of 3.9.4 as:

10/2

     type Security_Queue is new Queue with record ...;

11/2

     overriding
     procedure Append(Q in out Security_Queue; Person in Person_Name);

12/2

     overriding
     procedure Remove_First(Q in out Security_Queue; Person in Person_Name);

13/2

     overriding
     function Cur_Count(Q in Security_Queue) return Natural;

14/2

     overriding
     function Max_Count(Q in Security_Queue) return Natural;

15/2

     not overriding
     procedure Arrest(Q in out Security_Queue; Person in Person_Name);

16/2
The first four subprogram declarations guarantee that these subprograms will override the four subprograms inherited from the Queue interface. A misspelling in one of these subprograms will be detected by the implementation. Conversely, the declaration of Arrest guarantees that this is a new operation.