I\'d love to be able to do this:
class myInt : public int
{
};
Why can\'t I?
Why would I want to? Stronger typing. For example, I
More general than the fact that "int is primitive" is this: int
is a scalar type, while classes are aggregate types. A scalar is an atomic value, while an aggregate is something with members. Inheritance (at least as it exists in C++) only makes sense for an aggregate type, because you can't add members or methods to scalars — by definition, they don't have any members.