comp.lang.ada
 help / color / mirror / Atom feed
From: "Thomas Nebel" <thomas_nebel@gmx.de>
Subject: virtual functions in ada95
Date: Sat, 16 Jun 2001 19:31:07 +0200
Date: 2001-06-16T19:31:07+02:00	[thread overview]
Message-ID: <9gg557$8sgga$1@ID-42131.news.dfncis.de> (raw)

Hi

How can i use virtual functions in Ada? I have a superclass and some classes
that are derived
from it:

type TNTGL_Custom_Node_Record is tagged null record;
type TNTGL_Node_Record is new TNTGL_Custom_Node_Record with private;
type TNTGL_Visual_Node_Record is new TNTGL_Node_Record with private;
type TNTGL_Sphere_Record is new TNTGL_Visual_Node_Record with private;

type TNTGL_Node is access all TNTGL_Node_Record'Class;
type TNTGL_Sphere is access all TNTGL_Sphere_Record'Class;
....
procedure Run (Node : access TNTGL_Node_Record'Class);
procedure Run (Node : access TNTGL_Group_Node_Record'Class);
procedure Run (Sphere : access TNTGL_Sphere_Record'Class);

Now i want to "run" the classes from one point transparently :

Node : TNTGL_Node;
...
Node := Scene.First_Node;
while Node /= null loop
    Run (Node);
    Node := Get_Next (Node);
end loop;

Independent of the real type of the Node variable, the Run function is
always the Run from
TNTGL_Node_Record.

How can i manage it, that the Run function for the real Node type is called
?

Thomas





             reply	other threads:[~2001-06-16 17:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-06-16 17:31 Thomas Nebel [this message]
2001-06-16 19:08 ` virtual functions in ada95 David C. Hoos, Sr.
2001-06-16 19:43 ` tmoran
2001-06-18  3:24 ` Mark Lundquist
2001-06-18 18:54 ` Thomas Nebel
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox