4 ms·
I like the way the C++ FAQ explains the problems of "is a" inheritance, especially the examples of Circle-is-an-Ellipse. http://www.parashift.com/c++-faq-lite/
by CUViper 16y ago
I like the way the C++ FAQ explains the problems of "is a" inheritance, especially the examples of Circle-is-an-Ellipse.
http://www.parashift.com/c++-faq-lite/proper-inheritance.html http://www.parashift.com/c++-faq-lite/proper-inheritance.htm...
- Groxx 16y agoThat's a particularly accurate, bash-you-over-the-head-until-you-get-it explanation of the problems of inheritance. Nice link. I should really read through that whole FAQ/FQA some time, it's full of good stuff. I, personally, think of inheritance as it implies near the end: if A derives from B, A must effectively be B in all B-exposed methods. It can optimize, but it cannot change; A must pass any test B would pass, or it's not actually a B. But lots of code violates this. I think it's because a lot of people learn inheritance with the real-world connections in mind, and it's frequently taught to beginning programmers as a golden bullet. It can do a lot, but it has subtle surprises until you get better at programming.