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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3a34550290fdc12c X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-10 15:36:00 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!skynet.be!skynet.be!louie!tlk!not-for-mail Sender: lbrenta@lbrenta Newsgroups: comp.lang.ada Subject: Re: Problems with tagged records and inheritance References: From: Ludovic Brenta Date: 11 Jul 2003 00:29:52 +0200 Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Organization: -= Belgacom Usenet Service =- NNTP-Posting-Host: 217.136.22.171 X-Trace: 1057876521 reader1.news.skynet.be 303 217.136.22.171:35312 X-Complaints-To: usenet-abuse@skynet.be Xref: archiver1.google.com comp.lang.ada:40177 Date: 2003-07-11T00:29:52+02:00 List-Id: "Papastefanos Serafeim" writes: > The error is becouse AAA is not part of Child. > Why is that ? I thought that Child would contain > AAA and BBB, and not only BBB... I don't have all the details of your program, but I suspect that: - you have declared the two types Base and Child in different packages - you have defined the full view of Base in Base's private part - and that the package containing Child is not a child package of the one where you defined Base. This would explain that your Test procedure can only see the part of the Ch object that is declared in the same package. The part inherited from Base is private. If you want the Test procedure to see the internal details of Base, you must either declare Child in a child package or in the same package as Base. On the other hand, this would break encapsulation; is this really what you want? Here is a solution that does not break encapsulation: package One is type Base is tagged private; procedure Test (B : in Base); private type Base is tagged record -- The full view is private Aaa : Integer; end record; end One; package body One is procedure Test (B : in Base) is begin Put (B.Aaa); end Test; end One; with One; use One; package Two is -- Package Two is not a child of package One; therefore it cannot -- see the private part of package One. type Child is new Base with private; procedure Test (Ch : in Child); private type Child is new Base with record Bbb : Integer; end record; end Infant; package body Two is procedure Test (Ch : in Child) is begin One.Test (Base (Ch)); -- Delegate processing of invisible part -- Now, process the visible part: Put (Ch.Bbb); end Test; end Two; HTH -- Ludovic Brenta.