From: Dmitry A. Kazakov <mailbox@dmitry-kazakov.de>
Subject: Re: access on function returning a class wide type
Date: Wed, 20 Nov 2002 13:39:56 +0100
Date: 2002-11-20T13:39:56+01:00 [thread overview]
Message-ID: <udumtusv86bvjikji01mc748dbapt2pe14@4ax.com> (raw)
In-Reply-To: 20021119-223832-295143@foorum.com
On 19 Nov 2002 21:38:32 GMT, alex <xela@netcourrier.com> wrote:
>Is there a �workaround/trick� to implement this kind of think.
>
>package A is
> type A_T is abstract tagged null record;
> function Fa return A_T is abstract;
> type Fa_Ptr is access function return A_T'Class;
>end A;
>
>with A;
>package B is
> type B_T is new A.A_T with null record ;
> function Fa return B_T;
>end B;
>
>package body B is
> function Fa return B_T is
> begin return (A.A_T with null record);
> end Fa;
>end B;
>
>with A,B;
>procedure Test is
> Ptr : A.Fa_Ptr := B.Fa'access; -- error : LRM:8.6(28)
>begin null;
>end Test;
>
>The compiler is expecting a function returning a A_T�Class, ok I understand�
>But, B_T is in the A_T�Class!
You could wrap B.Fa in a function returning A_T'Class:
function Fa_b return A_T'Class is
begin
return B.Fa;
end Fa_b;
The question is why do you need something like that? Sort of lazy
object creation?
---
Regards,
Dmitry Kazakov
www.dmitry-kazakov.de
next prev parent reply other threads:[~2002-11-20 12:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-19 21:38 access on function returning a class wide type alex
2002-11-20 0:11 ` James S. Rogers
2002-11-20 6:39 ` alex
2002-11-20 8:43 ` Jean-Pierre Rosen
2002-11-20 12:39 ` Dmitry A. Kazakov [this message]
2002-11-20 15:32 ` Matthew Heaney
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox