ne one knows? a few lines on it?
ne one knows? a few lines on it?
Sounds a bit like a homework assignment .
A polymorphic function call is slower than an ordinary function call, but it allows the code that is using the polymorphic call to change and adapt more easily.
polymorphism is more an idea than anything concrete. it's the idea that the interface of a variety of functions and classes should be able to work together without a change in code. to be totally honest, it seems pretty important from what the books i've read told me. but i can't really see a big advantage to it. this kind of question sounds like a job for prelude.
Polymorphism replaces the 'structure embedded union' and 'case analysis' such as if/else or swith/case statements.
If you have a list of items and you want to loop through them and compute information it is easier to use polymorphism rather than adding case statements for each type of object. Polymorphism allows a group of hetrogenious objects to appear homogenious. It is effectively paired with iheritance.
I thought that polymorphism is what allows you to overload functions, have multiple inheritence, declare virtual functions, and assign base class pointers to derived classes. Basically do all those things that make classes and OOP handy.
"Logic is the art of going wrong with confidence."
Morris Kline
Most of the time they are used together however they are different. Overloading functions is used in specialization inheritance in order to preserve method names of the base classes (interfaces) but not behavior (implementation). Multiple inheritance involves deriving from two or more different base classes, and virtual functions are used with polymorphism in order for dynamic binding to take place (the objects are not known at compile time). They are not statically created.Originally posted by fletch
I thought that polymorphism is what allows you to overload functions, have multiple inheritence, declare virtual functions, and assign base class pointers to derived classes. Basically do all those things that make classes and OOP handy.
At least this is what I gather but I'm not exactly a C++er.