comp.lang.ada
 help / color / mirror / Atom feed
From: "David C. Hoos" <david.c.hoos.sr@ada95.com>
To: <comp.lang.ada@ada.eu.org>
Cc: <s_k_cole@yahoo.com>
Subject: Re: Simple Question 3
Date: Fri, 12 Oct 2001 08:33:20 -0500
Date: 2001-10-12T08:33:20-05:00	[thread overview]
Message-ID: <mailman.1002893515.9448.comp.lang.ada@ada.eu.org> (raw)
In-Reply-To: 9q49v5$6dj$1@trog.dera.gov.uk


----- Original Message -----
From: "Stephen Cole" <s_k_cole@yahoo.com>
Newsgroups: comp.lang.ada
To: <comp.lang.ada@ada.eu.org>
Sent: Thursday, October 11, 2001 9:28 AM
Subject: Simple Question 3


> Hi
>
> Question 3.....
>
> package MyTstTypes is
>    type MyRcd is tagged
>       record
>          a: Integer;
>          b: Float;
>       end record;
>
>    function Unit return MyRcd;
>
>    type MyNewRcd is new MyRcd with
>       record
>          c: Integer;
>       end record;
>
> --   function Unit return MyNewRcd;
>
>    type MyNewRcd2 is new MyNewRcd with
>       record
>          d: Float;
>       end record;
>
> end MyTstTypes;
>
> The compiler complains with the following text....
>
> "mytsttypes.ads:10:09: type must be declared abstract or "Unit"
overridden"
>
> It wants me to define a version of Unit() for each derived type?! Why?
>
Since the function Unit return MyRcd is not classwide, it can only return
values
of the type MyRcd.  If, instead, it were declared as
function Unit return MyRcd'Class, then it would be a classwide function
and it would return values of the type of the variable to which the function
result was being assigned, and the compiler would not complain.






  parent reply	other threads:[~2001-10-12 13:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-11 14:28 Simple Question 3 Stephen Cole
2001-10-11 22:41 ` tmoran
2001-10-12 11:33   ` Stephen Cole
2001-10-12 17:03     ` tmoran
2001-10-14  7:51     ` Jean-Marc Bourguet
2001-10-12 13:33 ` David C. Hoos [this message]
2001-10-14 18:53 ` Stephen Cole
2001-10-14 20:45   ` Vincent Marciante
2001-10-14 21:00   ` Jeffrey Carter
2001-10-14 22:08     ` Stephen Cole
2001-10-15  6:26       ` Jeffrey Carter
2001-10-14 21:15   ` Primitive operations and derived types (Was: Simple Question 3) Jacob Sparre Andersen
2001-10-14 21:42   ` Simple Question 3 tmoran
2001-10-14 22:30     ` Stephen Cole
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox