Forced typedefs.

Hello,

To help prevent logical bugs, I'm using a series of typedefs to separate conceptually different variables that use the same type. For example, 'NODE' and 'VALUE' are both just ints, but summing NODE vvariables makes no sense, while summing VALUE variables does.

Is there a way to enforce such things?
You could make a specific class derived from int, i use that when i want to prevent some implicit casts between variables stored in the same intrinsic type but that can't be operated with the normal operators.
Would that simply be a class with a single int member variable and redoing all operators? Seems like a lot (?) of overhead for simply trying to block implicit casts.
http://bytes.com/topic/c/answers/139957-built-type-inheritance

Using a class similar to the one in the link, will not cause any noticeable overhead (if any at all).
Topic archived. No new replies allowed.