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 X-Google-Thread: 103376,12527b153c400dab X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-08-30 09:16:03 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: Tagged types (beginner's question) ! Date: 30 Aug 2002 12:04:50 -0400 Organization: NASA Goddard Space Flight Center (skates.gsfc.nasa.gov) Message-ID: References: NNTP-Posting-Host: anarres.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: skates.gsfc.nasa.gov 1030724035 21266 128.183.220.71 (30 Aug 2002 16:13:55 GMT) X-Complaints-To: usenet@news.gsfc.nasa.gov NNTP-Posting-Date: 30 Aug 2002 16:13:55 GMT User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: archiver1.google.com comp.lang.ada:28597 Date: 2002-08-30T16:13:55+00:00 List-Id: Vincent DIEMUNSCH <"vincent.diemunsch"@edf.fr@NO.SPAM.PLEASE> writes: > Hello, > > I have a simple question concerning tagged types. Suppose that we have : > > type Rationnel is abstract new Ada.Finalization.Controlled with null > record; > > type Fraction is new Rationnel with record > Num�rateur : integer; > D�nominateur : positive; > end record; > > type Entier is new Fraction with null record; > > First Question : > Can I override the primitive operation "Adjust" of the controlled > type with the following : > procedure Adjust (F : in out Fraction'Class); > instead of : > procedure Adjust( F : in out Fraction); No. This would be "overloading", not "overriding". Calls to Adjust on an object of type Rationnel or Fraction made by the run-time system will not dispatch to this procedure. Adjust has a very specific meaning for Controlled types. Why do you want to do this instead? > Second question : How can Adjust (F : in out Fraction'Class) return > an object of type Entier instead of Fraction ? Note that Adjust is a procedure, so it does not "return" anything. Not clear what you really mean here. Again, why do you want to do this? If you are trying to emulate C++ constructors (just a wild guess), try defining: function New_Entier (...) return Entier; -- -- Stephe