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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM,WEIRD_PORT autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,94d84e4971c0caee,start X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!q16g2000yqq.googlegroups.com!not-for-mail From: Bryan Newsgroups: comp.lang.ada Subject: Inheritance with Ada types Date: Mon, 8 Feb 2010 18:16:14 -0800 (PST) Organization: http://groups.google.com Message-ID: NNTP-Posting-Host: 64.20.18.222 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1265681774 22242 127.0.0.1 (9 Feb 2010 02:16:14 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 9 Feb 2010 02:16:14 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: q16g2000yqq.googlegroups.com; posting-host=64.20.18.222; posting-account=kI3R0woAAAAkETUXcbnWjzzG0TUmJmXv User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:9013 Date: 2010-02-08T18:16:14-08:00 List-Id: I'm new to the OOP features of Ada and I'm trying to wrap my head tagged types. I've been reading the somewhat abstruse "Ada for Software Engineers" and while I understand the examples in the text, I would like to experiment on my own to further my understand. I'm trying to figure out how I can correctly--pardon my C++--"subclass" a base class to create a new derived "class". I created two simple packges as follows: parent.ads: with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; package Parent is type Parent is abstract tagged private; private type Parent is abstract tagged record Name: Unbounded_String; end record; end Parent; derived.ads: with Parent; use Parent; package Derived is type Derived is new Parent with private; private type Derived is new Parent with record Sub_Name: Unbounded_String; end record; end Derived; I can compile parent.ads and the object file and ALI file are produced. I'm unable to get derived.ads to compile, however. I get the following error: $ gnatmake -c parent derived.ads gcc -c derived.ads derived.ads:3:23: subtype mark required in this context derived.ads:3:23: found "Parent" declared at parent.ads:2 derived.ads:5:23: subtype mark required in this context derived.ads:5:23: found "Parent" declared at parent.ads:2 gnatmake: "derived.ads" compilation error If I make the Derived type in a child package of the parent package, I can get both interfaces to compile. Perhaps I am misunderstanding something about Ada OOP, but is it possible to have a derived package that is not a child package of the base? Must I use a child package, or keep the derived type in the same package as the base type?