From: "David Botton" <dbotton@hotmail.com>
Subject: Exposing agreggate members of a class
Date: 1998/12/30
Date: 1998-12-30T00:00:00+00:00 [thread overview]
Message-ID: <76cd39$21c8$1@news.gate.net> (raw)
Given:
with GCanvas_Package; use GCanvas_Package;
type GWindow_Object is tagged with private;
type GWindow_Pointer is access all GWindow_Object;
private:
type GWindow_Object is tagged
record
Canvas : GCanvas_Object;
end record;
What is the cleanest way to give access to the Canvas by reference in a way
that will not require Unchecked Programming
What I don't want:
function Get_Canvas( window : in GWindow_Object ) return GCanvas_Pointer
is
begin
return window.Canvas'Unchecked_Access;
end Get_Canvas;
Which on top of the Unchecked_Access issue means that consumers of such a
class would have to dereference first to use the GCanvas_Object methods:
declare
Canvas : GCanvas_Pointer := Get_Canvas( window );
begin
Draw_Line(Canvas.all, 10, 10, 100, 100);
end;
Of course you could write the methods to accept GCanvas_Pointer's, but I
want to avoid the use of Access variables when possible.
Thanks,
David Botton
next reply other threads:[~1998-12-30 0:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-12-30 0:00 David Botton [this message]
1998-12-30 0:00 ` Exposing agreggate members of a class Tom Moran
1998-12-31 0:00 ` LeakyStain
1998-12-31 0:00 ` David Botton
1999-01-03 0:00 ` Simon Wright
1999-01-06 0:00 ` 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