comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <spam@spam.com>
Subject: Re: please help - access and inheritence
Date: Sun, 07 Dec 2003 18:44:33 GMT
Date: 2003-12-07T18:44:33+00:00	[thread overview]
Message-ID: <lyKAb.4224$rP6.87@newsread2.news.pas.earthlink.net> (raw)
In-Reply-To: <3fd27939$1@news.barak.net.il>

Ratson Janiv wrote:
> type Vehicleptr is access Jr.Vehicle.Vehicle'Class;
> 
> type Vehiclesarr is array (1..Maxvehilces) of Vehicleptr;
> 
> Vp1,Vp2,Vp3,Vp4,Vp5: aliased Jr.Vehicle.Private_Car.Vehicle_Private;
> 
> Arr(1) := Vehicleptr(Vp1'access); -- failed, why? please ...

You could be a bit more clear about what the problem is. Does "failed" 
mean a run-time problem or a compiler error? In either case, more 
information about the "failure" would be helpful.

I note that Vehicleptr is not a general access type (access all 
<subtype>), but only allows access to values allocated on the heap 
(access <subtype>). Since Vp1'access does not designate a value 
allocated on the heap, it cannot be assigned to an object of type 
Vehicleptr. So if Arr (1) is a Vehicleptr [which seems likely, since 
you're trying to convert Vp1'access to Vehicleptr before assigning it to 
Arr (1)], the compiler should dissallow the assignment.

If you define Vehicleptr as access all ..., and Arr is declared as
Vehiclesarr, then you can write

Arr (1) := Vp1'access;

I guess saving the time to type an underline is more important than 
having code that is easy to read by using names such as Vehicle_Ptr.

-- 
Jeff Carter
"Every sperm is sacred."
Monty Python's the Meaning of Life
55




  parent reply	other threads:[~2003-12-07 18:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-07  0:47 please help - access and inheritence Ratson Janiv
2003-12-07  7:14 ` tmoran
2003-12-07 18:44 ` Jeffrey Carter [this message]
2003-12-08  4:46   ` Mr. J.
2003-12-08 18:07     ` Jeffrey Carter
2003-12-08 19:05       ` Martin Krischik
2003-12-08 19:17     ` Martin Krischik
2003-12-08 18:50 ` Martin Krischik
2003-12-09  5:58   ` Mr. J.
2003-12-09 16:55     ` Martin Krischik
replies disabled

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