This error usually occurs when the array size is not constant at compile time.
For example, if the user is trying to implement a stack using an array;
int elements[this->cap]; // <--- Errors here
This will display the following output;
Multiple markers at this line
- invalid use of 'this' at the top level
- array bound is not an integer constant before ']' token
In C, the size of an array must be a constant known at the compile time. You will get an error if that is not in any case.
Here, the user has;
Notice this->cap is not constant known at the compile time since it depends upon the size of the cap. If you have a variable size array whose size can be determined later then use std:: vector that can be resized at run time.
This error can also be solved by using the pointer implementation by;
int* elements = new int[cap];
I hope this will help to solve your error.