From: Stephen Leake <stephen.a.leake.1@gsfc.nasa.gov>
Subject: Re: Tagged types (beginner's question) !
Date: 30 Aug 2002 12:04:50 -0400
Date: 2002-08-30T16:13:55+00:00 [thread overview]
Message-ID: <uit1spc2l.fsf@gsfc.nasa.gov> (raw)
In-Reply-To: akkq54$kcq$1@clnews.edf.fr
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
prev parent reply other threads:[~2002-08-30 16:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-08-29 9:39 Tagged types (beginner's question) ! Vincent DIEMUNSCH
2002-08-30 13:35 ` Ted Dennison
2002-08-30 14:31 ` Pat Rogers
2002-08-30 16:04 ` Stephen Leake [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox