Compare these two situations:
class SuperClass
{
private var list:Array;
public function SuperClass()
{
list = new Array();
}
}
class SubClass extends SuperClass
{
// when instantiated, the list variable is automatically initialized
}
This is as it should be. The
the constructer gets invoked automatically (and its the only function which
does all other overrides this is not the case for) but the super class's
constructer is being called without arguments so whats happening on a code
level is this
super();
On 8/14/07, Alan MacDougall [EMAIL PROTECTED]
Hi,
when the superclass has a default contructor without parameters, there is no
need to call it explicitly.
I'd like to turn it around though, no matter what or how you have defined
them, always call them explicitly for clarity's sake and self documentation.
greetz
JC
On 8/14/07, Alan
On 8/14/07, Alan MacDougall [EMAIL PROTECTED] wrote:
My understanding of inheritance is that I should not need to explicitly
call the superclass constructor as long as I'm not overriding or
extending that method of the superclass. What gives? Is it a language
quirk?
Nope, not a language
Hans Wichman wrote:
Hi,
when the superclass has a default contructor without parameters, there is no
need to call it explicitly.
I'd like to turn it around though, no matter what or how you have defined
them, always call them explicitly for clarity's sake and self documentation.
So if the
Interesting thread, Alan!
What is ECMA Specification saying to that situation?
Matthias
slightly OT, but I have noticed some time ago, that Flash IDE claims
the super() call to be the first line in the constructor of the
extending class. But I noticed to the same time, that when compiling
with
6 matches
Mail list logo