title: Declaring a range for data members of a class
body: <p>I have to write this Course class, which has elements like <code>room</code>, <code>day_of_week</code> and so on.</p>
  
  <p>Each of them must be declared in a specific range for the course to be valid.</p>
  
  <p>For example, <code>day_of_week</code> must be an integer between 1 and 6, and <code>room</code> must be an integer between 1 and 599.</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>Sorry for the long read any help is welcomed.</p>