From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,933ebd8abdfd4df1 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-12-07 06:43:15 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!sn-xit-09!supernews.com!easynet-quince!easynet.net!teaser.fr!newsfeed.stueberl.de!newsfeed01.sul.t-online.de!newsmm00.sul.t-online.com!t-online.de!news.t-online.com!not-for-mail From: Martin Krischik Newsgroups: comp.lang.ada Subject: Re: oo programing question Date: Sun, 07 Dec 2003 15:01:23 +0100 Organization: AdaCL Message-ID: <4445978.xFQpVZx21n@linux1.krischik.com> References: <4948f537.0312061101.4155ad81@posting.google.com> Reply-To: krischik@users.sourceforge.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: news.t-online.com 1070808015 07 14227 +SfsGAj1GL+jwHv 031207 14:40:15 X-Complaints-To: usenet-abuse@t-online.de X-ID: V9nOLZZpQe90zpMnY7FdFsSpJt6zXt-0xVOFscZL-sTV3L-O68hUsA User-Agent: KNode/0.7.2 Xref: archiver1.google.com comp.lang.ada:3201 Date: 2003-12-07T15:01:23+01:00 List-Id: 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