don't understand unhandled exception

Hello,
I'm having problems with a game I am making, when I run it I get this error message and I don't understand it.

Unhandled exception at 0x000a2259 in AllegroAnimation.exe: 0xC0000005: Access violation writing location 0x0000000c.

this is the file that the exception happens it stops as void GameObject::Init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "GameObject.h"

GameObject::GameObject()
{
	x =0;
	y = 0;

	velX = 0;
	velY = 0;

	dirX = 0;
	dirY = 0;

	boundX = 0;
	boundY = 0;
	
	maxFrame = 0;
	curFrame = 0;
	frameCount = 0;
	frameDelay = 0;
	frameWidth = 0;
	frameHeight = 0;
	animationColumns = 0;
	animationDirection = 0;

	image = NULL;

	alive = true;
	collidable = true;
}

void GameObject::Destroy()
{

}

void GameObject::Init(float x, float y, float velX, float velY, int dirX, int dirY, int boundX, int boundY)
{
	GameObject::x = x;
	GameObject::y = y;

	GameObject::velX = velX;
	GameObject::velY = velY;

	GameObject::dirX = dirX;
	GameObject::dirY = dirY;

	GameObject::boundX = boundX;
	GameObject::boundY = boundY;
}

void GameObject::Update()
{
	x += velX * dirX;
	y += velY * dirY;
}

void GameObject::Render()
{}

bool GameObject::CheckCollisions(GameObject *otherObject)
{
	float oX = otherObject->GetX();
	float oY = otherObject->GetY();

	int obX = otherObject->GetBoundX();
	int obY = otherObject->GetBoundY();

	if( x + boundX > oX - obX &&
		x - boundX < oX + obX &&
		y + boundY > oY - obY &&
		y - boundY < oY + obY)
		return true;
	else
		return false;
}
void GameObject::Collided(int objectID)
{}

bool GameObject::Collidable()
{
	return alive && collidable;
}


Please help, I don't know error codes. I don't know why it won't run.
I don't know a thing about Allegro, but try to change all lines like GameObject::x = x; to this->x = x;, if x and others are not static.
Well I changed all of the functions to in GameObject::Init to that and it just gave me the same exact error message, thank you though.
Sounds like you're dereferencing a null pointer. When you get the access violation... select "Retry" or whatever the option is in the popup box to snap the debugger. It will take you right to the offending line of code.

Examine variable contents (open up a "Watch" window) and make sure your indexes are in bounds and your pointers are non-null.
I don't know a thing about Allegro, but try to change all lines like GameObject::x = x; to this->x = x;, if x and others are not static.

Even better, don't use the same names for your parameters and your data members. It can only lead to confusion.
So I got it working, for the most part, it gets past that now and Disch you were right, I had forgotten to even declare the pointer, but now the program runs but does nothing and while I was debugging it i got to the a point where the debugger just wouldn't step into the functions (it was a while statement), then when I try to close the window with either the exit button or the esc button, neither works, so I close the console window and continue debugging and it tells me there is an error in a file called crt0dat.c on this line, anyone know what that means? I didn't even make this file so I have no idea why there would be an error in it.

onexitbegin_new = (_PVFV *) DecodePointer(__onexitbegin);
Topic archived. No new replies allowed.