* Question: constuctors
@ 1998-08-10 0:00 Maxim Senin
1998-08-10 0:00 ` Robert Dewar
1998-08-10 0:00 ` Robert Dewar
0 siblings, 2 replies; 3+ messages in thread
From: Maxim Senin @ 1998-08-10 0:00 UTC (permalink / 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1998-08-10 0:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-08-10 0:00 Question: constuctors Maxim Senin
1998-08-10 0:00 ` Robert Dewar
1998-08-10 0:00 ` Robert Dewar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox