回复 5# 104359176 |
interface ==> class's type
- class cat
- class dog
- c: cat // c is cat [type cat, class is a type!]
- d: dog // d's type is dog
- c, d have a different type?? cat vs dog?
- If we have noah's arc [what is all the anim's class?? Off Course! Animal]
- In static lang's container must be have same type! how to do that?
- Give it a interface? [what's interface? So easy! It's a class type ]
- You'll find? cat is animal ==> interfase: Animal
- You'll find? dog is animal ==> interfase: Animal
- What's cat or dog's type?
- OK it is Animal!
- We have A train to the Zoo: (limitations: same types?)
- OK: dog1, dog2,.... (dog1 is a classA, dog2 is a classA....)
- NG: dog1, cat1, dog2,... different type!!
- So? You'll find? tiger? Cat? Dog....they all different type?
- a class is a type: cat , dog, tiger.....
- but an interface A: may be ? cat, dog,...
- So? interface is a class's type!!
- train = cat, dog, tiger, lion, cat....[NO problem, They all have the same type Animal!!]
- That's All