In the Ada programming language, it's possible to declare a type or sub-type, like this:
type DAYS_OF_YEAR is range 1 .. 366;
type PERSONS_AGE is range 0 .. 120;
which in this case means unsigned integers that can only be in the given range.
At run-time, if a variable of that type is ever assigned a value out of its range, an exception is thrown.
What's the best way of implementing something similar in C++ 11?
Last edited on
Last edited on
Thanks Cubbi, your answer was very helpful.
Tony
Last edited on