comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Heaney <matthew_heaney@acm.org>
Subject: Re: Constructors?
Date: 1998/08/27
Date: 1998-08-27T00:00:00+00:00	[thread overview]
Message-ID: <m3ogt7tf0n.fsf@mheaney.ni.net> (raw)
In-Reply-To: slrn6u4oir.1pf.franke@pax10f.mipool.uni-jena.de

franke@minet.uni-jena.de (Frank Ecke) writes:

> Yes, you can call a superclass constructor from a descendent class
> constructor.  But beware, although the term constructor exists in Ada,
> it should not be confused with the notion used in OO.  For example, in
> Java, constructors are not inherited by the subclass.  In Ada, a
> constructor is simply a primitive operation of a tagged type and,
> therefore, it is propagated into the subclass.

Not necessarily.  In fact, the usual rule of thumb is declare
constructors so that they are NOT primitive operations of the type.

You can do this be declaring the constructors in a nested package, or
just return the class-wide type as the return value.

One time when you do want to make the constructor primitive is when you
need it to dispatch, as in the case of a factory method.




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

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <35DF0616.77764632@tech.swh.lv>
1998-08-25  0:00 ` Constructors? Frank Ecke
1998-08-25  0:00   ` Constructors? Tucker Taft
1998-08-27  0:00   ` Matthew Heaney [this message]
replies disabled

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