Error When Compiling at End of Lesson

I’m rerunning through the course content again to make sure I’m fully understanding everything and I ran into this error after we create getScreenPos( ) override function. Not sure why, can someone help please?

Hey there,

Well, based on the error message “Segmentation Fault” it is saying that it is a specific kind of error caused by accessing memory that does not belong to the class (as far as I understand).

Did you check if your functions are virtual and overriding? I’d need to check the rest of the code to help further.

Tell me if anything

Hello!
I figured out the issue, and I’ll sort of expand on it as well for anyone else who looks this sort of thing up. So what I had done was created an instance of a class outside of the while loop, which everyone knows creates an object of the class that can be used to access member variables/methods. After that, I had accidentally tried accessing a method from inside of the while loop, but had done so AFTER another method was accessed that needed the parameter inputs from the first method. In C++, the order in which the code is placed is crucial as the code executes from top to bottom. I was basically trying to run a method that needed the updated input parameters of the other method, which caused the segmentation fault error because that variable wasn’t updated according to the structure of the code. I caught it by looking at the debug log, and then tracing the code back to where the debug log said the segmentation fault was starting and realizing at that point it was accessing something that didn’t exist each time the while loop executed. It was a simply mistype on my part but I was stuck on this for quite a while. Thanks for the help in this.

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms