dalcocer 0 Newbie Poster

I am trying to get a WndProc Mapping solution to work so that I can avoid just making my WndProc static. In addition, a mapping solution is supposed to be great because I don't need to declare variables in my .cpp file, I can do it in my .h file like it should be.

However, this is exactly my problem: if you uncomment lines 3 and 4 of GameManager.cpp and you comment lines 24 and 25 of GameManager.h, the program runs just fine. But, I need it to be the other way around! Instead what happens is the window opens and closes abruptly. Any insight would be greatly appreciated:

*Edit: sorry if the post is too long, I'm new to these forums. If it's too long just let me know and I'll cut out things I *think* are not causing this issue. However, a big reason I left it is so someone can compile it (it should compile and run straight out of the box!).

main.cpp:

#include "GameManager.h"	// Include our GameManager and let it handle everything.
#include <windows.h>
int WINAPI WinMain(	HINSTANCE	hInstance,			// Instance
					HINSTANCE	hPrevInstance,		// Previous Instance
					LPSTR		lpCmdLine,			// Command Line Parameters
					int			nCmdShow)			// Window Show State
{
	GameManager gameManager;
	GameManager *gm = &gameManager;
	return gm->run();
}

GameManager.h:

#ifndef GAMEMANAGER_H
#define GAMEMANAGER_H

#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "glu32.lib")

#include <windows.h>		// Header File For Windows
#include <gl\gl.h>			// Header File For The OpenGL32 Library
#include <gl\glu.h>			// Header File …
dalcocer 0 Newbie Poster

Thanks!

dalcocer 0 Newbie Poster

I was running into run time errors, and stripped down my code to isolate the problem. From that I was able to write this little piece of code to demonstrate my issue:

#include <windows.h>

class test
{
private:
	int a;
public:
	test();
	void run();
};

test::test()
{
	a = 5;
}
void test::run()
{
	a = 6; // comment this to prevent the runtime error.

}



int WINAPI WinMain(	HINSTANCE	hInstance,			// Instance
					HINSTANCE	hPrevInstance,		// Previous Instance
					LPSTR		lpCmdLine,			// Command Line Parameters
					int			nCmdShow)			// Window Show State
{
	test* t;
	t->run();

}

This gives me an unhandled exception in visual studio c++ 2005. I don't understand what's bad about it. Making anything static is not an option and neither is a declaring the "a" variable in the cpp file (in my version, all of this is split up properly between header and cpp).

Any insight on how to better handle this would be greatly appreciated!