I do not think loki7
has much of a point. If you need objects
, that's what the wrapper classes
ar for - for each primitive type, there is a class that just wraps its value. Thus, no need for duplicate code or overloading.
Something else that sets the primitive types apart from objects is that they are passed by value, not by reference. This might be seen as both a feature (because quite often you want to pass something by value, and always having to use clone() is annoying), and a bug (because it introduces an inconsistency).
Finally, if even numbers were objects, you'd almost inevitably start having to overload or redefine operators (for what if you derived your own class from the number classes, changed it completely and still wanted to use normal arithmetic operators?), and that usually (IMO) results in a huge, ugly mess.