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,c9a5d6b3975624e1 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-10-08 08:39:27 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!sn-xit-03!sn-xit-06!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: "Matthew Heaney" Newsgroups: comp.lang.ada Subject: Re: OO in Ada Date: Tue, 8 Oct 2002 11:37:42 -0400 Organization: Posted via Supernews, http://www.supernews.com Message-ID: References: <3da2aafd.7023559@news.demon.co.uk> X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Complaints-To: abuse@supernews.com Xref: archiver1.google.com comp.lang.ada:29591 Date: 2002-10-08T11:37:42-04:00 List-Id: "John McCabe" wrote in message news:3da2aafd.7023559@news.demon.co.uk... > > If you make the tagged type declaration private and still want > inheritance your extensions of the tagged type must be created in > child packages of the original tagged type. This isn't quite right. There is *always* inheritance when a type derives from another type. If the parent type is tagged, then you're allowed to extend the parent type's representation. What you really meant is that you don't have *visibility* to the parent's private presentation, unless the type is declared in a child package. If you derive from a type, you always inherit its representation and operations (that's what "primitive operation" means). > >:) However, if in a program 'use'ing the child package of 'Thick_Pen' (and > >not mentioning the base package of 'Pen') I make a call to the routine > >'Draw' with an actual parameter of the type 'Pen' I get a compiler error > >message to the effect that 'Draw' is not visible. In other words, Thick_Pen > >has not inherited the operation Draw for 'Pen' Again, > >_there_is_no_inheritace_. > > There is an easy answer to this that I can't remember at the moment. > It's probably to do with using 'Class somewhere, but it may be that > you have an incorrect declaration somewhere that isn't actually a > creating a dispatching operation. Yes, something is indeed wrong with the parent declaration. If the operation is primitive, then it gets inherited. _There_is_always_inheritance_of_primitive_operations. > >5. One final thing (for this time anyway ;), why is it that that Ada does > >not use the intuitive 'object.method' syntax for making calls to and object. Why is package P is type T is tagged limited private; function "=" (L, R : T) return Boolean; ... end; any different from: namespace N { class C { ... private: C& operator=(const C&); C(const C&); }; bool operator==(const C& lhs, const C& rhs); } Are you saying binary operations in C++ aren't intuitive? If I do this: Push_Back (List, Item); then is there any question that I'm appending a new element, with the value Item, to the back of object List?