Class vs. Interface

后端 未结 10 1476
孤城傲影
孤城傲影 2020-12-10 03:18

I have a quite basic question:

When should we decide to use Interface or Class for a specific class?

For example: says we have 2 classes, Customer and Doctor

10条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-10 03:41

    Parent Class is the one which will have bare minimum properties common to all of its sub classes.

    But Interface is a contract which tells its implantations to provide if it is not an abstract class.

    And the One important difference between a class and interface is that

    class inheritance will give relation between two common subclasses.

    Where as Interface implementation gives a relation between two uncommon classes.

提交回复
热议问题