Polymorphic Driver
MC logo

Polymorphic Driver

Ada Code Examples

<<Listing Sequence Class Body Download OO Generalized Stack Package>>
with Gnat.Io; use Gnat.Io;

with Compcount;
with Inccount;
with Listseq;
with Mulcount;
with Seqpack;

use Compcount;
use Inccount;
use Listseq;
use Mulcount;
use Seqpack;

procedure Drive is
   type CPtr is access all Sequence'class;
   A: aliased AdditiveSequence;
   B: aliased MultSequence;
   C: aliased ListSequence;
   Arr: array(1..3) of CPtr := (A'Access, B'Access, C'Access);
   SetList(C, (5, 1, 7, 4));
   Init(A, 3, 2);
   Init(B, 1, 3);

   for I in 1..15 loop
     for J in 1..3 loop
        Put(Arr(J).all); Put(" ");
     end loop;
   end loop;
end Drive;
<<Listing Sequence Class Body OO Generalized Stack Package>>