What is the best approach for creating a generic number class in C ++? I am thinking of an object that can contain integers, float and double.
My first idea is to use a union, which will be used in a number class, where you can define the allowed operations for each type. Sort of:
union mixed_number{ int a; float b; double c; }; class Number{
Please let me know if there is a better approach.
mmisu source share