comp.lang.ada
 help / color / mirror / Atom feed
* accessing subprogram & inheritance problem
@ 2001-02-05 23:12 VC
  2001-02-06  4:43 ` tmoran
  2001-02-08  1:53 ` Robert Brantley
  0 siblings, 2 replies; 6+ messages in thread
From: VC @ 2001-02-05 23:12 UTC (permalink / raw)


How do I make the following program to compile and work?
I would like to have a subprogram pointer in the root class which
can be used to point to the subprograms in the child class as well.
Is it possible at all with Ada95?

Vicky
---------------------------------------------------------------
with Ada.Text_Io;
use Ada.Text_Io;

procedure Mytest is

   type Root_T;

   type Action_Ptr_T is access
     procedure(Object : in Root_T);

   type Root_T is tagged
      record
         Action_Ptr : Action_Ptr_T;
      end record;

   procedure Root_Action (Object : in Root_T) is
   begin
      Put_Line("Root Action");
   end;

   type Child_T is new Root_T with null record;

   procedure Child_Action (Object : in Child_T) is
    begin
      Put_Line("Child Action");
   end;

   My_Object : Root_T;
   My_Child : Child_T;

begin

   My_Object.Action_Ptr := Root_Action'Access;
   My_Object.Action_Ptr(My_Object);  -- this printed out "Root Action"

   My_Child.Action_Ptr := Child_Action'Access;
   My_Child.Action_Ptr(My_Child);  -- would like it to print "Child Action"

end Mytest;






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

end of thread, other threads:[~2001-02-08 18:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-02-05 23:12 accessing subprogram & inheritance problem VC
2001-02-06  4:43 ` tmoran
2001-02-06  7:59   ` Sven Nilsson
2001-02-08  1:53 ` Robert Brantley
2001-02-08  4:36   ` tmoran
2001-02-08 18:48     ` Robert Brantley

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