What's inheritance and why's it useful?
Printable View
What's inheritance and why's it useful?
Wrong thread for this but.. inheritance is when someone dies or something and it passes onto you. You get it because it belongs to you and otherwise who knows where it would go.
The beauty of inheritance in C++ is that the class doesn't have to die for you to get what it has. ;)
Well, thats a rather open ended question. Basically, it allows you to derive classes from a base class(es). There are many uses. For example, if you have a pointer (or reference) to the base class, it could actually be one of the derived classes, but you can treat it just as the base class. Really, there is too much to explain in this thread. For a brief example, see the thread by ygfperson entitled something to the effect of "What is the best way to..." (too lazy to post a link... perhaps later).
I could only give you a little information, but have you looked here:
http://www.google.com/search?hl=en&i...B+%2B+tutorial