comp.lang.ada
 help / color / mirror / Atom feed
* Polymorfism Question
@ 2000-08-19  0:12 moasi
  0 siblings, 0 replies; only message in thread
From: moasi @ 2000-08-19  0:12 UTC (permalink / raw)


I have a linked list. And i have done several classes and subclasses.
So i create objects of different classes and make a heterogeneous list.
Now i want to print the list. Each element in list has different
fields, so when i ask for the list i don't get all the fields
but just the basics. How can i alter that?
Here is my program:

procedure Print_All_Obligations(MyList: access List) is

        Current_Ptr : Obligation_Ptr;
        CheckMyList : Integer_Check;

  begin
    Reset_Cursor(MyList);
    Current_Ptr := Obligation_Ptr(Return_Cursor(MyList));
    if Current_Ptr /= null then
    begin
      Print(Current_Ptr);
      loop
        CheckMyList := Go_Next_Element(MyList);
        exit when CheckMyList /= 0;
        New_Line;
        Current_Ptr := Obligation_Ptr(Return_Cursor(MyList));
        Print(Current_Ptr);
      end loop;
    end;
    else Put_Line ("--> Nothing In List!");
    end if;
   New_Line;
end Print_All_Obligations;

The classes starting for the top are:
element --> obligation --> meeting --> b_meeting and p_meeting 
the last 2 are in the same level (they both have meeting as their parent).
All classes except the element have a print, and when i call
the print of b_meeting, it prints something then calls the print
of meeting and the print of meeting calls the print of obligation.
I have also declared pointers for each class like that
type Element_Ptr is access all Element'Class;
                            
In general how can i understand each time in what kind of
element am i so that i can print the correct fields?

Please feel free to give any hints, remarks or advices!

-- 
Antonis Zisimos



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2000-08-19  0:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-08-19  0:12 Polymorfism Question moasi

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