Re: abstract class inheritance

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Joerg Jooss (joerg.jooss_at_gmx.net)
Date: 09/10/04


Date: Fri, 10 Sep 2004 17:16:33 +0200

Claire wrote:
> I have a base abstract class A which contains several abstract
> functions
> I then have an abstract class B (derived from A) which overrides a
> small subset of A's abstract functions
>
> Finally I have a fully functional class C (deriving from B). Class C
> overrides the (A's) abstract functions not tackled by its ancestor B.
>
> I am complained at by the compiler, that in C, I have not implemented
> the inherited abstract members defined by A. But I overrode these
> functions in B!
>
> Is this correct and why?
>
> Claire
>
> public abstract class A
> {
> public abstract void Function1();
> public abstract void Function2();
> public abstract void Function3();
> }
>
> public abstract class B : A
> {
> public override void Function1()
> {
> doodar;
> }
> }
>
> public class C : B
> {
> public override void Function2()
> {
> }
> public override void Function3()
> {
> }
> // Compiler complains that C has not implemented Function1
> }

It should compile. And it actually does for me (.NET 1.1, VS .NET 2003).

Cheers,

-- 
Joerg Jooss
joerg.jooss@gmx.net 


Relevant Pages

  • abstract class inheritance
    ... I have a base abstract class A which contains several abstract functions ... public abstract void Function1(); ... public override void Function1() ...
    (microsoft.public.dotnet.languages.csharp)
  • Serviced Components
    ... This abstract base class is inherited by another abstract class. ... in addition to defining an explicit interface. ... WARNING: The class 'Ori.APatient' has no class interface, ... public abstract class AOrderObjects: ServicedComponent, ...
    (microsoft.public.dotnet.framework.interop)
  • Re: abstract class inheritance
    ... did you miss out the override keyword on one of the method implementations ... > I then have an abstract class B which overrides a small ... > public abstract void Function1(); ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: OOP 101 - Inheritance confusion
    ... public abstract class IAccount ... > I'm writing a simple accounting type application. ... > that instead of an abstract class I should create a base class with the ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: abstract class inheritance
    ... > I then have an abstract class B which overrides a small ... > public abstract void Function1(); ... > public override void Function1() ...
    (microsoft.public.dotnet.languages.csharp)