From: Martin Krischik <krischik@users.sourceforge.net>
Subject: Re: oo programing question
Date: Sun, 07 Dec 2003 15:01:23 +0100
Date: 2003-12-07T15:01:23+01:00 [thread overview]
Message-ID: <4445978.xFQpVZx21n@linux1.krischik.com> (raw)
In-Reply-To: 4948f537.0312061101.4155ad81@posting.google.com
shoko wrote:
> i have the following code:
>
> package a is
> --car class --
> type a is tagged private;
There are two schools here:
1. Packages are multiples and objects are singles:
package Cars is
type Car is ...
2. Packages are singles and objects are Object:
Package Car is
type Object is
Calling the Type the same as the package gets you into trouble when code
becomes more complex.
> type a_ptr is access all car'class;
Use "access" and not "access all" whenever possible.
> with a;
>
> package b is
> type b is new a.a with private; <-- constraint error
> type b_Ptr is access all b'Class;
>
> function init_b(maximum:positive) return b_Ptr;
Are you shure you need a access here? Adas stack handling is far more
powerfull then C++'s. So you might be better of just to return 'b'. Look at
New_Object in
http://adacl.sourceforge.net/html
______Include__AdaCL-SAR-Filter-Replace__adb.htm
> private
> type b is new a.awith
> record
> maximum_:positive;
> end record;
> end b;
> -------------------------------------------
> in the main procedure:
>
> with a;use a;
> with b;use b;
don't "use" everything.
> procedure main is
> new_b:b_ptr;
>
> begin
> new_b := init_b(90);
> end main;
>
> i get constraint error on b.ads
> i dont understand why
Difficult without the package bodys.
With Regards
Martin
--
mailto://krischik@users.sourceforge.net
http://adacl.sourceforge.net
next prev parent reply other threads:[~2003-12-07 14:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-12-06 19:01 oo programing question shoko
2003-12-06 20:18 ` Stephen Leake
2003-12-07 14:01 ` Martin Krischik [this message]
-- strict thread matches above, loose matches on Subject: below --
2003-12-07 21:14 shoko
2003-12-08 19:04 ` 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