From: "Mattias" <mpedv98@student.vxu.se>
Subject: Problem with dynamic dispatching (Polymorphism)
Date: 1999/04/25
Date: 1999-04-25T00:00:00+00:00 [thread overview]
Message-ID: <7fvfcm$cfi$1@news.lth.se> (raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1314 bytes --]
Hi!
I�m developing a simple linked list to hold different data types..
I have to one superclass , with two derived classes..
I have declared a 'Class type which I use to access all of my structures,
I have no trouble adding data to the list. The error occures when I wan't to
extract the data and Print it to the screen..
look at the following code example:
program.ads:
type T�cken is tagged null record;
type Siffra is new Tecken with
Record
Element : Integer;
end record;
procedure Print(S : Siffra);
type Bokstav is new T�cken with
record
Element : Character;
end record;
procedure Print(B : Bokstav);
type pTecken is access all Tecken'Class;
program.adb
-- I have to simple procedures which Print the values of Class bokstav,
'' notice .. pekare is of type pTecken ..
procedure Print(B : Bokstav) is
begin
Put(B.Element);
end Print;
procedure Print(S : Siffra) is
package Iio is new Integer_Io(Integer);
use Iio;
begin
put(S.Element);
end Print;
-- Then I have this procedure to extract the elements from the list. Pekare
is
Pocedure Display is
begin
while Lista /= null loop
Print(Lista.Pekare);
Lista := Lista.Next;
end loop;
end Display;
Really need help on this one
thx
Mattias
next reply other threads:[~1999-04-25 0:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-04-25 0:00 Mattias [this message]
1999-04-25 0:00 ` Problem with dynamic dispatching (Polymorphism) Bo Sanden
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox