I can use either a struct or an enum to overload constructors, and they both seem to do the same job. in fact, changing from one to the other doesn’t even show any differences when diff’ing the two executables using each. But, which is proper?
This:
enum PointLocalCoord{ local };
enum PointGlobalCoord{ global };
class Point {
Point( const PointLocalCoord, const int x, const int y )
{ /* something */ }
Point( const PointGlobalCoord, const int x, const int y )
{ /* something else */ }
};
or This:
struct local{};
struct global{};
class Point {
Point( const local, const int x, const int y )
{ /* something */ }
Point( const global, const int x, const int y )
{ /* something else */ }
};
Neither is good. You should have strongly semantic types, even for quantities of the same dimension, and conversion functions between them:
Now you can make constructors for each point type directly.
The upshot here is that a semantic point class is much better than two random, meaningless integers.