1.多态:一个非面向对象编程的编译器产生的函数调用会引起所谓的前期绑定,也就是面向过程,调用函数地址在编程时就已经确定了,面向对象编程(oop),程序直到运行时才能够确定代码的地址,也就是后期绑定,在向对象发送消息时,动态绑定调用的方法。
定义一个方法:
doSomething(Shape shape){ doA(); doB(); }
多态实现:向上转型,子类看做是基类的过程是向上转型
Circle circle = new Circle() Triangle triangle = new Triangle() doSomething(ricle); doSomething(triangle);
ps:43页