0
void merge(vector<Flight>& data, int low, int high, int mid, string criteria)
{
int i, j, k, temp[high - low + 1];
...

The error that comes up is "the value of parameter "high" (declared at line 100) cannot be used as a constant". I haven't managed to find an appropriate answer to this question online.

asymmetryFan
  • 712
  • 1
  • 10
  • 18
  • You are trying to use `high` as array length in a declaration. As the compiler tells you, that's not possible. – user0042 Nov 28 '17 at 09:01

1 Answers1

4

high - low + 1 needs to be a compile time evaluable constant expression in C++. (C++ does not support variable length arrays.)

And that isn't, so the compiler issues a diagnostic.

The simple solution is to use a std::vector<int> as the type for temp.

Bathsheba
  • 231,907
  • 34
  • 361
  • 483