Re: Inheritance question



relient <xllx.relient.xllx@xxxxxxxxx> wrote:
Oh, yes... One last thing I forgot to say above (which was my primary
question; hehe) is: override and abstract in the same signature doesn't
make much sense to me. I mean, It's not like you can create an instance
of class "Derived" and assign it to a variable of type class Base, to
use in polymorphism, because it's abstract. I do, however, understand
if it was "new abstract" but, "override abstract"? what's up with that
confusing signature?

It's not that confusing - it basically means that the derived class
*has* to implement the method, and it's an override so that if someone
has:

Base b = new Third();
b.DrawYourself();

it will still call the overridden method in Third. (If it were "new
abstract" in Derived, the above would call Base.DrawYourself.)

--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.



Relevant Pages

  • Re: The Override Problem
    ... >> occasionally override. ... >> get the method signature off by a hair. ... > JBuilder provides an "override method" wizard which can insert stubs ... > for all inherited abstract methods and can insert stubs for selected ...
    (comp.lang.java.programmer)
  • Re: feature question
    ... a base method BM with signature "C M;" ... an override OM with signature "D M;" ... DerivedFactory GetFactoryin the DerivedObject class ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: method overriding
    ... Parent Parent.method ... Nothing like that is possible for Java, in fact, I haven't ... would override Parent.method if all slots in the child method's signature ...
    (comp.lang.java.programmer)
  • Re: override by name in c#?
    ... > public int Add ... That's not an override - it doesn't have the override modifier. ... That seems odd if you've changed the signature - it shouldn't. ... > because it's not the same signature, it does, and apart from the warning, this ...
    (microsoft.public.dotnet.languages.csharp)
  • override by name in c#?
    ... public int Add ... This seems to work, but it generates a warning 'the new specifier is needed, ... But even though I didn't think this would work to override the base class ... because it's not the same signature, it does, and apart from the warning, this ...
    (microsoft.public.dotnet.languages.csharp)