This error is hard to solve and it may appear in many cases, so improve the article by adding as many cases as possible.
-
The solution for this problem is specific to each implementation, but there are some common mistakes to avoid. For example, the elements of a vector must be filled with the pointers, not the objects themselves. Detailed solution manual about this error message will be given later.
-
Avoid exceeding arrays. Don't do this:
int *x;
int a = 0,b = 0,c =0;
x = new int[1];
x[0] = a;
x[1] = b;
x[2] = c;
This code works, but if you continue to allocate memory, you may encounter this error message in the future.