Fri, 1 May 1998 10:15:42 -0400
|
I agree that it is unfortunate that people have equated
C++ constructors with the "Initialize" procedure of
controlled types. They really have little in common.
The "Initialize" procedure is somewhat related to the
"default" (parameterless) constructor, but even there,
it is rarely needed, because normal default initialization
in Ada is usually sufficient to accomplish what a C++
default constructor does.
Parameterized constructors in C++ or Java are best represented
by functions or procedures in Ada. Ada 95 allows a type
to be declared in a way that you must explicitly initialize
all instances, by using the "unknown discriminants" notation
in the private type declaration. This then allows any
function that returns the type to be used as a parameterized
constructor.
Oh well...
If anyone is interested in writing a comment on this article,
I hope it will be "upbeat" in saying that in addition to
the mechanism suggested in the article, Ada 95 also provides
a much more flexible mechanism based on functions and/or procedures.
-Tuck
|
|
|