the object will find speak method automatically
ex:
Shape *a = [Circle new];
[a draw];
note: Circle's draw method is called
In java, you have to change object's type to People to call People's method
ex:
Shape a = new Circle();
In java, you have to change object's type to People to call People's method
ex:
Shape a = new Circle();
a.draw(); // Shape's draw method is called
(Circle)a.draw(); // Circle's draw method is called
(Circle)a.draw(); // Circle's draw method is called
沒有留言:
張貼留言