From: Stephen Leake <Stephen.Leake@gsfc.nasa.gov>
Subject: Re: virtual C++ functions in Ada?
Date: 1998/10/28
Date: 1998-10-28T00:00:00+00:00 [thread overview]
Message-ID: <uzpagcny3.fsf@gsfc.nasa.gov> (raw)
In-Reply-To: 36343E19.624E8BB0@ilt.fhg.de
Rolf Wester <WESTER@ilt.fhg.de> writes:
> Hi,
>
> I tried to write a small Ada-program similar to a C++ programm which
> uses virtual functions. But it does not work. The C++ prgramm is:
>
<snip>
> package optelements is
> ...
> procedure transform(OE : in OptElem; b : in out beam);
> ...
> procedure transform(OE : in Propagator; b : in out beam);
> -- this works
> ...
> procedure transform(OE : access Mirror; b : in out beam);
> -- this does not work
>
> end optelements;
> In the Ada program I get dynamic dispatching only when using objects for
> the function parameters not when using access types. Is there anything
> wrong?
'access Mirror' is not the same as 'Mirror'; the parameter type
profile for 'transform' on Mirror does not match that for 'transform'
on OptElem. Do get dynamic dispatching on an access value, you must
do:
package optelements is
...
procedure transform(OE : access OptElem; b : in out beam);
...
procedure transform(OE : access Propagator; b : in out beam);
...
procedure transform(OE : access Mirror; b : in out beam);
end optelements;
all 'access', or all 'in' (or two variants of 'transform' for each
class).
Why did you want 'transform' on Mirror to be different?
-- Stephe
prev parent reply other threads:[~1998-10-28 0:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-10-26 0:00 virtual C++ functions in Ada? Rolf Wester
1998-10-28 0:00 ` 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