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.7 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,5f0f4bfb0467bb19,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.27.230 with SMTP id w6mr12147383pbg.3.1317325236303; Thu, 29 Sep 2011 12:40:36 -0700 (PDT) Path: lh7ni7705pbb.0!nntp.google.com!news1.google.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: "Rego, P." Newsgroups: comp.lang.ada Subject: Constructors with multiple inheritance Date: Thu, 29 Sep 2011 12:40:28 -0700 (PDT) Organization: http://groups.google.com Message-ID: <11513972.2788.1317325228383.JavaMail.geo-discussion-forums@yqnv12> Reply-To: comp.lang.ada@googlegroups.com NNTP-Posting-Host: 200.148.121.121 Mime-Version: 1.0 X-Trace: posting.google.com 1317325230 24200 127.0.0.1 (29 Sep 2011 19:40:30 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 29 Sep 2011 19:40:30 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=200.148.121.121; posting-account=TRgI1QoAAABSsYi-ox3Pi6N-JEKKU0cu User-Agent: G2/1.0 X-Google-Web-Client: true Xref: news1.google.com comp.lang.ada:18206 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2011-09-29T12:40:28-07:00 List-Id: Hi people I have a package which implements a class with two items which actually are= classes which builds different kind of queues. One of them is a queue whos= e items are of the kind of the parent class. I need to implement a construc= tor to the parent class, then I need to implement the constructors for the = two queues. For me, it`s more intuitive from OO point of view that the thre= e constructors are implemented as methods (not just independent calls), and= that was just the point where I got stuck. So, the packages are declared as=20 ------------------------ -- parent_package.ads -- ------------------------ limited with Parent_Package.Child_Package; package Parent_Package is type Parent_Class is tagged record Child : access Child_Package.Parent_Queue_Class; Modes : access Child_Package.Modes_Queue_Class; end record; type Parent_Class_Ptr is access all Parent_Class; function Construct (Sender : in Parent_Class) return Parent_Class_Ptr; end Parent_Package; ------------------------ -- parent_package.adb -- ------------------------ with Parent_Package.Child_Package; package body Parent_Package is function Construct (Sender : in Parent_Class) return Parent_Class_Ptr is New_Parent : constant Parent_Class_Ptr :=3D new Parent_Class; begin New_Parent.Child :=3D Sender.Child.Construct; New_Parent.Modes :=3D Sender.Modes.Construct; return New_Parent; end Construct; end Parent_Package; -------------------------------------- -- parent_package-child_package.ads -- -------------------------------------- package Parent_Package.Child_Package is type Parent_Queue_Class is tagged record Next : access Parent_Queue_Class; Parent : access Parent_Class; end record; type Parent_Queue_Class_Ptr is access all Parent_Queue_Class; function Construct (Sender : in Parent_Queue_Class) return Parent_Queue_= Class_Ptr; type Modes_Queue_Class is tagged record Next : access Modes_Queue_Class; Mode : Integer; end record; type Modes_Queue_Class_Ptr is access Modes_Queue_Class; function Construct (Sender : in Modes_Queue_Class) return Modes_Queue_Cl= ass_Ptr; end Parent_Package.Child_Package; -------------------------------------- -- parent_package-child_package.ads -- -------------------------------------- package body Parent_Package.Child_Package is function Construct (Sender : in Parent_Queue_Class) return Parent_Queue_Class_Ptr is pragma Unreferenced (Sender); New_Queue : constant Parent_Queue_Class_Ptr :=3D new Parent_Queue_Cla= ss; begin return New_Queue; end Construct; function Construct (Sender : in Modes_Queue_Class) return Modes_Queue_Class_Ptr is pragma Unreferenced (Sender); New_Queue : constant Modes_Queue_Class_Ptr :=3D new Modes_Queue_Class= ; begin New_Queue.Mode :=3D 0; return New_Queue; end Construct; end Parent_Package.Child_Package; --------------------- -- parent_main.adb -- --------------------- with Parent_Package; procedure Parent_Main is Obj : Parent_Package.Parent_Class_Ptr; begin Obj :=3D Obj.Construct; end Parent_Main; --------------------------- when I build the code, I get the messages: warning: useless assignment to "Obj", value never referenced (ok, I agree = sure) warning: null value not allowed here warning: "Constraint_Error" will be raised at run time =09 and sure when I execute the code I get=20 raised CONSTRAINT_ERROR : parent_main.adb:5 access check failed (BTW, if I implement the constructors independent from the class - i.e. wi= thout referencing the parent class as the argument -, they return no error = message and the results after that are according to expected, but sure it b= reaks the oo design.) So, how can I fix this? Thanks!