Author: zf19921020
* Reprint Please indicate the source *
From the basic situation of the error is that the definition of vector vectors subscript overrun, and through the search and their own inquiry, reported the possibility of the following kinds of errors.
1, a vector for the violation of the subscript access, that is, when the vector is not initialized with the [] operator to access the vector, here is explained that the recommended way to access vectors is the use of vectors: Access by iterator or by using the Vector.at method. Before accessing the subscript, you must ensure that the position of the vector represented by the subscript is present, because the compiler does not check the error for you, but only when the programmer himself checks for code.
2, in the function or a scope to define a pointer to the vector and not manually delete it is also possible to report this error, because the memory is not released, it is possible to generate such errors, the recommendation here is the definition of pointers and use of smart pointers to complete, that is, shared_ptr, which is a new feature of c++11 , you can automatically manage and release pointers to objects. The shared_ptr is defined in the memory header file.
3, the last kind of error situation is very special, using VS2013+OPENCV for human face and human eye recognition, if the confirmation vector is not overrun, also no use of the pointer is not released, but the single-step debugging found in leaving some functions of the function of the report vector subscript out of Range this error or _CRTISVALIDHEAP, it is possible that your VS13 version is linked to the 10 version of the VS OpenCV library. We can see it through the solutiong->properties->configuration properties->vc++ directorys->library Directorys, If the address of the OPENCV's link library contains VC10, then the vs2010 version of the link is linked, and VS12 represents vs2013 and the above version.