Re: overides/loads usage

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Thank you very much for responding.

#1 ok. I understand now. Is the new constructor the only procedure that
executes the new() in base before the derived?

#2 But why not always use overloading or shadowing rather than overriding?
It seems that you can accomplish what you need with overloading and
shadowing especially since to override (as you said) requires the
overridable keyword in base class. When do I use overloading verses
shadowing?

Thanks again.

"Scott M." <s-mar@xxxxxxxxxxxxx> wrote in message
news:uuxZK6QqGHA.4408@xxxxxxxxxxxxxxxxxxxxxxx
i see that the base class has a new procedure with no arguments. The
arguments in both base and derived classes are the same. Is the new
procedure in the derived class shadowing or overriding the new procedure
in base class? I understand that it would be easy to tell if the coder
specified keyword of overrides or shadows, but they didn't.

The answer is neither. Constructors are "special", in that, they neither
shadow or override other constructors from their base classes. Take this
example:

Public Class A
Sub New()

End Sub
End Class

Public Class B
Inherits A
Sub New()

End Sub
End Class

If you were to make an instance of "B", the constructor from class "A"
will fire and then the constructor from class "B".


#2 In another derived class I see two new procedures. One with no
parameters like one in base class and the other with two parameters. I
understand that the constructor is overloaded, but is the new with no
parameters shadowing or overriding the new in base class.

Nether again. The constructor in the derived class that takes the
parameters is overloading the constructor in the derived class AND the
constructor in the base class.

How can one know if shadowing is being used or if overriding is being
used when no keyword is specified in procedure declaration?

Simple. To use Shadowing or Overloading in VB.NET, the Shadows and
Overrideable and Overrides keywords MUST be specified. If you don't see
those words, they are not being used.


Thanks in advance.





.



Relevant Pages

  • Re: overides/loads usage
    ... shadowing especially since to override requires the ... When do I use overloading verses ... It's Overriding and Shadowing that are similar, ... Marking a class member as Overridable means that in derived classes, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: overides/loads usage
    ... overloading and shadowing especially since to override ... Overriding ... Marking a class member as Overridable means that in derived ...
    (microsoft.public.dotnet.languages.vb)
  • Re: overides/loads usage
    ... overloading and shadowing especially since to override ... Overriding ... Marking a class member as Overridable means that in derived ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Copy Constructor Craziness
    ... There is no copy constructor involved at all. ... because I don't see any justification for this autogeneration. ... If you're overloading a mutator, there needs to be a copy ...
    (comp.lang.perl.misc)
  • Re: still crabby about copy constuctor craziness
    ... When the copy constructor gets ... or if a mutator has been explicitly overloaded. ... newest version explicitly overloads them. ... > no such thing as a copy constructor, and no operator overloading. ...
    (comp.lang.perl.misc)