Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

how to define range of numbers inside a if condition in c++

template <int min, int max> class range {
  static bool contains(int i) { return min <= i  && i < max; } // In C++, ranges usually are half-open.
};

int age = 23;
if (range<18,30>::contains(age)) { 
//Your desired code
}
 
PREVIOUS NEXT
Tagged: #define #range #numbers #condition
ADD COMMENT
Topic
Name
5+7 =