An Interface with Abstract Methods

前端 未结 2 487
眼角桃花
眼角桃花 2021-01-26 07:48

I came across some PHP code that was written by a co-worker (it was not used for anything). Basically it was an interface containing abstract methods. I then said that this was

相关标签:
2条回答
  • 2021-01-26 08:40

    All methods in an interface are abstract by definition.

    An abstract method is a method for which the prototype is supplied but not implemented. It forces subclasses to implement it, or be declared abstract.

    0 讨论(0)
  • 2021-01-26 08:48

    No, it's not useful. He should either use abstract classes or just plain interfaces.

    Interface methods are basically abstract anyway, so having abstract interface methods doesn't make much sense.

    0 讨论(0)
提交回复
热议问题