Polymorphism

Hi,

I'm trying to understand and practice Polymorphism, but I don't understand something. When a tutorial started to explain Inheritance, it gave as the main reason to use it is "code reuse". But when using polymorphism, you're writing code again, right? So you're not really reusing code?

EDIT:
Second question:
Why would you override virtual functions?

For example, you have a base class with virtual void testfunction();, but the derived class also has a virtual void testfunction();. Why do you need to override the one in the derived class?
Last edited on
I would explain this, but this site's tutorial does a better job IMO lol:

http://www.cplusplus.com/doc/tutorial/inheritance/#inheritance
and
http://www.cplusplus.com/doc/tutorial/polymorphism/#virtual
Hmmm, there was a part in the tutorial explaining this, which I didn't notice yet. Thank you anyway :)
Topic archived. No new replies allowed.