Syntax

  • Thread starter Thread starter yma
  • Start date Start date
Y

yma

Hi,

In a subclass, is

sub new()
end sub

the same as

sub new()
mybase.new()
end sub


Thanks

Chris Ma
 
No,

the first instantiates <subclass>::new(), and if it exists in the base
class, overrides it so that the <baseclass>::new() is not called.
the seconds does the first, but then calls any instantiation of the
baseclass as well...

the second is used if you have something that's initialised in the base
class, which you want initialised, but then wish to further initialise in
some way...

for example...

base class is called Animal
the sub class is called Dog

you may say that an animal as the class action, which then calls initialises
breathe...
but then the Dog calls this base initialisation and calls Bark... you want
both Bark and Breathe to be initialised or the dog won't be barking for
long!
 
Back
Top