Okay this is a bit of a noobish question, but I ran across this today and it somewhat puzzles me WHY it would be this way.
Consider the following structure
Public Class Employee
Implements IPerson
Private _MyManager As Manager
Public Property MyManager() As Manager Implements IPerson.TheirLeader
Get
Return _MyManager
End Get
Set(ByVal value As Manager)
_MyManager = value
End Set
End Property
End Class
Public Class Manager
Implements IPerson, IAuthorityFigure
Private _MyBoss As Boss
Public Property MyBoss() As Boss Implements IPerson.TheirLeader
Get
Return _MyBoss
End Get
Set(ByVal value As Boss)
_MyBoss = value
End Set
End Property
End Class
Public Class Boss
Implements IPerson, IAuthorityFigure
'Implementation code here...
End Class
Public Interface IPerson
Property TheirLeader() As IAuthorityFigure
End Interface
Public Interface IAuthorityFigure
'Stuff here...
End Interface
Here is my question: I am wanting to have every person implement the IPerson interface, whether they are an employee, boss, or manager. However, they each have an attribute that refers to their leader (employees have a manager, managers have a boss, etc). Each implementation of their leader could be potentially differnt other than they fact that they implement the IAuthorityFigure interface. I am wanting to have the IPerson interface have a property for the IAuthorityFigure, but it throws a compiler error for me when I implement this b/c the IAuthorityFigure is not the same type as Boss or Manager (even though they implement the interface).
So, I am doing something wrong, or is this a limitation of using interfaces versus abstract classes. If this is a limitation, can anyone explain why it is so?
Thanks!