constructor methods in interfaces

后端 未结 6 2178
闹比i
闹比i 2021-02-18 21:03

Are constructor methods in interfaces bad?

6条回答
  •  伪装坚强ぢ
    2021-02-18 21:16

    Whether or not they are bad, I am not aware of any language that has the ability to specify a constructor on an interface.

    That being said, however, I personally do not believe that the constructor of an object is part of that object's interface and as such adding a constructor to an interface would inhibit the natural flexibility that interfaces afford.

提交回复
热议问题