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

C++
-1

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
}
Posted by: Guest on June-15-2021

Code answers related to "how to define range of numbers inside a if condition in c++"

Browse Popular Code Answers by Language