comp.lang.ada
 help / color / mirror / Atom feed
From: "Maxim Senin" <maks.tech.swh.lv>
Subject: Question: constuctors
Date: 1998/08/10
Date: 1998-08-10T00:00:00+00:00	[thread overview]
Message-ID: <6qmnl5$1lq@news.latnet.lv> (raw)

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






             reply	other threads:[~1998-08-10  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-08-10  0:00 Maxim Senin [this message]
1998-08-10  0:00 ` Question: constuctors Robert Dewar
1998-08-10  0:00 ` Robert Dewar
replies disabled

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