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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ebc448503c153b4c,start X-Google-Attributes: gid103376,public From: "Maxim Senin" Subject: Question: constuctors Date: 1998/08/10 Message-ID: <6qmnl5$1lq@news.latnet.lv>#1/1 X-Deja-AN: 379677797 Organization: LatNet news site X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Newsgroups: comp.lang.ada Date: 1998-08-10T00:00:00+00:00 List-Id: I'm thinking about writing constuctors for my ADA 95 program. Do you know any tips/tricks/hints how to write constuctors in ADA? What is extension agregate? Samples? I've tried following code, but it doesn't compile with my GNAT 3.07 for DOS. -- package spec -- ... type Object is tagged private; type PObject is access all type Event is new Object with private; type FocusEvent is new Event with private; type KeyEvent is new Event with private; private type Object is new ADA.Finalization.Controlled with null record; type Event (src : PObject) is new Object with record source : PObject := src; consumed : Boolean := false; end record; type FocusEvent is new Event with null record; type KeyEvent (code : Integer; mask : Integer; typeOfEvent : Integer) is new Event with record keyCode : Integer := code; altMask : Integer := mask; eventType : Integer := typeOfEvent; end record; -- package body -- function newKeyCode (aSource : PObject; aKeyCode : Integer; aMask : Integer; anEventType : Integer) is return new KeyCode' (src => aSource, keyCode => aKeyCode, altMask => aMask, eventType => anEventType); end newKeyCode; <<<<<<<< This doesn't work. Compiler crashes: it requires extension agregate becouse KeyCode has private ancestor Event, and Event has private ancestor Object and so on. How newly created objects should be initialized????? What is extension agregate? In addition, I don't like this way of providing constuctors. If I will have class derived from KeyEvent, I will have to rewrite such constructor complettly. Any suggestions? Thanks you very much. Maxim