Hi,

I'd like to do be able to implement an interface in a derived class by
relying on the base class for some of the members. For example like
this:

Interface ITest
Property prpA() As Integer
Property prpB() As Integer
End Interface

Public MustInherit Class BaseClass
Public Property prpA() As Integer
Get
Return 1
End Get
Set(ByVal Value As Integer)

End Set
End Property
End Class

Public Class DerivedClass
Inherits BaseClass
Implements ITest

Public Property prpB() As Integer Implements ITest.prpB
Get
Return 0
End Get
Set(ByVal Value As Integer)

End Set
End Property
End Class

But the compiler doesn't recognise prpA as being present in
DerivedClass. Can anyone tell me how I could get round this, and also
why it should be that this is not allowed?

Thanks,

Gareth

RE: Implementing an interface by relying on base class by Schmeusser

Schmeusser
Wed Jun 08 03:25:06 CDT 2005

Maybe you could use C# as the problem does not exist there

interface IPoint
{
// Property signatures:
int x
{
get;
set;
}

int y
{
get;
set;
}
}

class BasePoint
{
private int myX;

// Property implementation:
public int x
{
get
{
return myX;
}

set
{
myX = value;
}
}
}

class MyPoint : BasePoint, IPoint
{
// Fields:
private int myY;

// Constructor:
public MyPoint(int x, int y)
{
x = x;
myY = y;
}


public int y
{
get
{
return myY;
}
set
{
myY = value;
}
}
}



"Gareth" wrote:

> Hi,
>
> I'd like to do be able to implement an interface in a derived class by
> relying on the base class for some of the members. For example like
> this:
>
> Interface ITest
> Property prpA() As Integer
> Property prpB() As Integer
> End Interface
>
> Public MustInherit Class BaseClass
> Public Property prpA() As Integer
> Get
> Return 1
> End Get
> Set(ByVal Value As Integer)
>
> End Set
> End Property
> End Class
>
> Public Class DerivedClass
> Inherits BaseClass
> Implements ITest
>
> Public Property prpB() As Integer Implements ITest.prpB
> Get
> Return 0
> End Get
> Set(ByVal Value As Integer)
>
> End Set
> End Property
> End Class
>
> But the compiler doesn't recognise prpA as being present in
> DerivedClass. Can anyone tell me how I could get round this, and also
> why it should be that this is not allowed?
>
> Thanks,
>
> Gareth
>
>