Implementing an interface by relying on base class

G

Gareth

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
 
G

Guest

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;
}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top