Original Post
I'm using Visual C++ 2008 Express Edition, and using the book, "Programming Role-Playing Games with DirectX, by Jim Adams." And I'm having a problem with this static pointer. Here is the static pointer being initialized: /* static cApplication *g_pApplication = NULL; */ cApplication is the class that handles most of the Windows code. The class also has a default message procedure. g_pApplication is the class pointer. What I'm trying to do is overload the message procedure. Here is the overloaded message procedure code: /* static long FAR PASCAL WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_DESTROY: PostQuitMessage(0); return 0; default: return g_pApplication->MsgProc(hWnd, uMsg, wParam, lParam); } } */ Here is the code for the default message procedure code: /* virtual long FAR PASCAL MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { return DefWindowProc(hWnd, uMsg, wParam, lParam); } */ When the code compiles, in the Output window, it shows this error: /* First-chance exception at 0x7c918fea in Game Files.exe: 0xC0000005: Access violation writing location 0x00000010. */ It still compiles, but I want to know why it prints out the exception. Also, I want to know if it's a good idea to use the static pointer or just have the static message procedure. Thanks.