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 could define two classes intA
and intB
, which let me do intA + intA
or intB + intB
, but not intA + intB
.
"Ints aren't classes." So what?
"Ints don't have any member data." Yes they do, they have 32 bits, or whatever.
"Ints don't have any member functions." Well, they have a whole bunch of operators like +
and -
.