user2340426
user2340426

Reputation: 225

Does a Class extended from a Base which uses an Interface ever need to also use the same Interface?

This questions comes from my AS3 history, but I think the concept applies to all languages. I can't go back to check the original code but it has been bothering me for a while and would appreciate some clarity.

I was tasked with writing a game, MyGame, that extended a GameBase class. The template I had been told to follow required that the game use an IGame interface, but I found that that the GameBase class also used that same interface.

Lacking proper notation, I think about it like this:

   MyGame : GameBase
     |          |
   IGame      IGame

This looks redundant to me and I want to know whether it was or whether I misunderstood inheritance in this context.

Upvotes: 1

Views: 36

Answers (1)

null
null

Reputation: 5255

The sub class inherits all super types, that includes the interfaces. There's no need to implement that interface again, because it is already implemented.

Upvotes: 2

Related Questions