comp.lang.ada
 help / color / mirror / Atom feed
* virtual functions in ada95
@ 2001-06-16 17:31 Thomas Nebel
  2001-06-16 19:08 ` David C. Hoos, Sr.
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Thomas Nebel @ 2001-06-16 17:31 UTC (permalink / 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





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2001-06-18 18:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-16 17:31 virtual functions in ada95 Thomas Nebel
2001-06-16 19:08 ` David C. Hoos, Sr.
2001-06-16 19:43 ` tmoran
2001-06-18  3:24 ` Mark Lundquist
2001-06-18 18:54 ` Thomas Nebel

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