I have defined an interface for a data structure type. I am trying to force whatever class implementing that interface to also implement two other interfaces (iterator and countable).
Is there a way to do this?
I have defined an interface for a data structure type. I am trying to force whatever class implementing that interface to also implement two other interfaces (iterator and countable).
Is there a way to do this?
Have your interface implement them and then just pass on the abstract methods (i.e. don't implement the methods in your interface)
If you want to force it, you could declare that your interface extends the interfaces you required, e.g.
interface c extends a, b
{
...
}
Generally speaking though, you should probably be writing code which checks that an object has all the interfaces required for a particular operation before carrying it out. Makes things easier to maintain and extend in the long run...