| Mark Smith ( |
It means many things, but commonly, polymorphism is just a fancy way of saying that an object satisfies several classes. This is most useful in the situation where you have, say,
class MyBase;
implements Foo, Bar;
class MyRealClass inherits from MyBase;
implements Foo;
class MyOtherClass inherits from MyBase;
implements Bar;
Elsewhere, you can say that something takes a MyBase and in reality, someone can pass it a MyRealClass. For the purpose of that function, you treat MyRealClass as MyBase... it is polymorphic. I.e., has several forms. But when you call Foo on it, it's actually calling MyRealClass::Foo, not MyBase::Foo. Even though the function in question doesn't know what a MyRealClass is.
(This is an example of late/dynamic binding, an implementation of polymorphism, -- read more at http://en.wikipedia.org/wiki/Dynamic_bi nding_(computer_science) if you're curious. But in reality, it can mean other things, too. The word itself is polymorphic! Augh!)
class MyBase;
implements Foo, Bar;
class MyRealClass inherits from MyBase;
implements Foo;
class MyOtherClass inherits from MyBase;
implements Bar;
Elsewhere, you can say that something takes a MyBase and in reality, someone can pass it a MyRealClass. For the purpose of that function, you treat MyRealClass as MyBase... it is polymorphic. I.e., has several forms. But when you call Foo on it, it's actually calling MyRealClass::Foo, not MyBase::Foo. Even though the function in question doesn't know what a MyRealClass is.
(This is an example of late/dynamic binding, an implementation of polymorphism, -- read more at http://en.wikipedia.org/wiki/Dynamic_bi
(Reply to this) (Thread from start) (Parent) (Thread)
