From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00,CTE_8BIT_MISMATCH, INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,d6fce62235e109c0 X-Google-Attributes: gid103376,public From: Jerome Desquilbet Subject: Re: Can you help with an Ada 95 OO Problem Date: 1997/01/21 Message-ID: <32E4C727.1CFB@Rational.COM>#1/1 X-Deja-AN: 211300410 references: to: David Wallace content-type: text/plain; charset=iso-8859-1 organization: Rational Software Corporation in (the) SQY, France mime-version: 1.0 newsgroups: comp.lang.ada x-mailer: Mozilla 3.0 (X11; I; OSF1 V3.2 alpha) Date: 1997-01-21T00:00:00+00:00 List-Id: David, First, some comments about the compilability of the program you posted: - You have to supply a body for Http.Headers.Debug - The body Http.Headers.General_Headers.Init does not compile because in procedure Init (Obj : access General_Header) is Header_Ref : Header_Access := Obj; begin ... end Init; "OBJ is not a value of HEADER_ACCESS" - There's another semantic problem in Http.Headers.General_Headers.Debug I don't know if I well understood your problem. However, I have built a program handling something similar (again if I understood well). I.e. how to initialize an object, starting by initializing its "inner parent object". I don't think I would create and initialize objects exactely like that, but never mind. I hope this example will help you. Good luck, J�r�me. package Base is type Object is tagged private; procedure Initialize (A_Base : access Object); procedure Debug (A_Base : in Object); private type Object is tagged record Data : Integer; end record; end Base; with Ada.Text_Io; package body Base is Arbitrary_Data : constant Integer := 4; procedure Initialize (A_Base : access Object) is begin Ada.Text_Io.Put_Line ("Initializing a base object... begin"); A_Base.all.Data := Arbitrary_Data; Ada.Text_Io.Put_Line ("Initializing a base object... end"); end Initialize; procedure Debug (A_Base : in Object) is begin Ada.Text_Io.Put_Line (Integer'Image (A_Base.Data)); end Debug; end Base; with Base; package Derived is type Object is new Base.Object with private; procedure Initialize (A_Derived : access Object); procedure Debug (A_Derived : in Object); private type Object is new Base.Object with record Data : Character; end record; end Derived; with Ada.Text_Io; package body Derived is Arbitrary_Data : constant Character := 'e'; procedure Initialize (A_Derived : access Object) is begin Ada.Text_Io.Put_Line ("Initializing a derived object... begin"); Base.Initialize (Base.Object (A_Derived.all)'Access); A_Derived.all.Data := Arbitrary_Data; Ada.Text_Io.Put_Line ("Initializing a derived object... end"); end Initialize; procedure Debug (A_Derived : in Object) is begin Base.Debug (Base.Object (A_Derived)); Ada.Text_Io.Put (A_Derived.Data); Ada.Text_Io.New_Line; end Debug; end Derived; with Derived; procedure Try_Derived is D : aliased Derived.Object; begin Derived.Initialize (D'Access); Derived.Debug (D); end Try_Derived; ______________________________________________________________________ Jerome Desquilbet jDesquilbet@Rational.COM ' ^