I have to write this Course class, which has elements like room
, day_of_week
and so on.
Each of them must be declared in a specific range for the course to be valid.
For example, day_of_week
must be an integer between 1 and 6, and room
must be an integer between 1 and 599.
My question is, is there a way to write my constructor so that when I initialize an object with invalid data it will not compile.
Putting it in another perspective, is there a way to declare the range of my data members in the constructor or in the class declaration.
Sorry for the long read any help is welcomed.