I have been having this problem for a few days now and I can find nothing on how to fix it. I am not exactly new to c++ but I have never had an error like this one :
Unhandled exception at 0x014621fa in Tanks.exe: 0xC0000005: Access violation reading location 0xfeeefeee.
The program that I am writing currently has one class that will eventually be used to draw menus, using a library that my university has written themselves named Gwin.
As it stands I am not even sure where the error is coming from as when I use the debugger all the variables seem to be in order and there is nothing out of place that I can see. I have posted most of the code below:
Menu(string Title, GImage Picture, int x, int y, GImage Bkg, GWindow &Gwin);
void DrawMenu(GWindow &Gwin);
void AddOption(GImage Opt, int Code);
int Tposx, Tposy;
0xfeeefeee is an address that appears in DEBUG builds (under Visual Studio anyway) when a pointer has not been set to anything. (it's a helper to find memory leaks)
You'll have to step through your code or set a break point near where the error occurs or set break points around any pointers in the code and look for a pointer that contains 0xfeeefeee at the point of the exception. From there you can workout how to properly initialise and delete the pointer correctly.
Set a breakpoint at that line and have a look at the Watch window (If you use visual studio it's under the Debug menu, Windows->Watch->Watch1.
Type Start into the window that pops up and also Gwin and look for any pointers containing 0xfeeefeee. That should give us a clue on where to look next.
OK, so your best bet is probably going to be stepping through the code (using F10 and F11 I think in Visual Studio) and seeing where/when they dissapear, using F11 you can step into the functions where Start and GWin disappear and maybe see whats going on?
Seems a bit wierd that you can't see Start when a breakpoint is set on that line though?!??
where does "gwin.h" and it's library/source come from?
OK, have gone through the code step by step, but something has confused me even more. Basically, it is completely fine, then at the end of the function AddOptions(), where the curly ending bracket is, it throws the error, not during the statements to add stuff into the vectors... So yes, I really don't understand that. Any ideas?
If it happens at the end of a function, it could be a problem with destructors. Are you passing pointers to stack variables anywhere? The functions/classes might be trying to delete them or possibly use them after they are destroyed.
@ Moooce - The Gwin stuff is something that my university created. There is an msi installer for it, but it only works in visual studio as far as I am aware. You should be able to download it from here if you wanted to: https://warren.ntu.ac.uk/projects/gwin/files
OK, I have looked to see about passing pointers and things, but I am not doing that anywhere so I don't think it can be that. Also, I was wondering if I am using the private keyword correctly in my class declaration?
Sorry for tripple posting but: I removed the call to AddOptions() and it works fine, however then, when I end the program it gives me the same error... So I don't think it something exactly to do with that function...
If you're using Visual Studio, turn on Exception trapping and run in the debugger. The program will stop when the exception is raised. Break into it (it'll prompt you) and take a look at the call stack.