From: el97165@central.ntua.gr (moasi)
Subject: Polymorfism Question
Date: 19 Aug 2000 00:12:07 GMT
Date: 2000-08-19T00:12:07+00:00 [thread overview]
Message-ID: <slrn8prjaf.mj.el97165@ntomata.localdomain> (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
reply other threads:[~2000-08-19 0:12 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox