In the following code in my program (simplified of course), the output in funcA and funcB are different, meaning the pointer's value got changed somewhere along the way. I wasn't able to comfirm that the address of face
changed as this error magically doesn't pop up in the debugger (QT Creator's debugger). But here's the code:
void funcA() {
Face *face = funcB();
if (face != NULL) {
cout << "in funcA " << face->vertices[0] << endl;
}
}
Face * funcB() {
vector<Face> faces;
//populate faces
...
Face *face = &(faces[index]);
cout << "in funcB " << face->vertices[0] << endl;
return face;
}
Though the output changes depending on where my mouse clicks, the output in the two functions above vary wildly (in funcB it would be for example 30, and in funcA it would become 18117600 ... I only have 60 faces!) Also it seems to show up randomly, not all the time.
Any assistance will be greatly appreciated.