Without discussing whether or not it’s a good idea, What type of drawbacks (performance or otherwise) would one face if they were to encapsulate the built-in C++ data types into their own classes. For instance, similar to Java and C#, the int data type would have its own class called Int, overloading it with inline operators. Same with Single, Double, Long, etc.
Without discussing whether or not it’s a good idea, What type of drawbacks (performance
Share
There are no benefits. You cannot achieve identical behavior, nor performance.
Drawbacks:
You have Java stuck in your head.
C++ takes the template approach:
Now you have a function that works on any type that supports the correct operators. This will work for built-in types, and classes such as
Int128.