Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

What are the practical consequences of differences in Smalltalk/C++ inheritance?

0
Posted

What are the practical consequences of differences in Smalltalk/C++ inheritance?

0

[For context, please read the previous FAQ]. Smalltalk lets you make a subtype that isn’t a subclass, and allows you to make a subclass that isn’t a subtype. This allows Smalltalk programmers to be very carefree in putting data (bits, representation, data structure) into a class (e.g., you might put a linked list into class Stack). After all, if someone wants an array-based-Stack, they don’t have to inherit from Stack; they could inherit such a class from Array if desired, even though an ArrayBasedStack is not a kind-of Array! In C++, you can’t be nearly as carefree. Only mechanism (member function code), but not representation (data bits) can be overridden in subclasses. Therefore you’re usually better off not putting the data structure in a class. This leads to a stronger reliance on abstract base classes. I like to think of the difference between an ATV and a Maseratti. An ATV (all terrain vehicle) is more fun, since you can “play around” by driving through fields, streams, sidewalk

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123