| − | Polymorphism allows an object to be used in place of an ancestor object without the code that is using it having to know about the descendant. This means that a complex object can appear to be a simple one. The example below shows that you can have a specific model of car, such as the [[Model T]], which looks like and acts like a normal car. Polymorphism can be implemented in different ways. Smalltalk implemented it via messages. Most compilers that support OOP implement a virtual method table, which is an array of method pointers as per the CORBA standard. A descendant class instance can be used in place of any ancestor class instance, but an ancestor class instance cannot be used in place of a descendant class instance. | + | Polymorphism allows an object to be used in place of an ancestor object without the code that is using it having to know about the descendant. This means that a complex object can appear to be a simple one. The example below shows that you can have a specific model of car, such as the [[Model T]], which looks like and acts like a normal car. Polymorphism can be implemented in different ways. [[Smalltalk]] implemented it via messages. Most compilers that support OOP implement a virtual method table, which is an array of method pointers as per the CORBA standard. A descendant class instance can be used in place of any ancestor class instance, but an ancestor class instance cannot be used in place of a descendant class instance. |