Problem writing to location

Started by
1 comment, last by MaulingMonkey 18 years, 3 months ago
"Unhandled exception at 0x0041e019 in map.exe: 0xC0000005: Access violation writing location 0xcdcdcdd9." I'm getting the above error in my program when I try and set values of variables in a class through a second class. The code is:

void MAP::AddRooms()
{
	int length = (maxy * maxx) + 2;
	for (int i = 1;i < length;i++)
	{
		int type = GetMapArrayElement(i);		
		roomlist[i-1]->SetY(i);
		roomlist[i-1]->SetType(type);
		roomlist[i-1]->SetExplored(false);
		roomlist[i-1]->SetPlayerin(false);
		roomlist[i-1]->SetMap(GetMap());
		roomlist[i-1]->SetX(i);			
	}
}
for calling the functions to set the variables from within the second class

void ROOM::SetX(int xnumber)
{
	x = xnumber;
}
void ROOM::SetY(int ynumber)
{
	y = ynumber;
}
void ROOM::SetMap(int mnumber)
{
	map = mnumber;
}
void ROOM::SetExplored(bool value)
{
	explored = value;
}
void ROOM::SetType(int typeno)
{
	type = typeno;
}
void ROOM::SetPlayerin(bool value)
{
	playerin = value;
}
For setting the variables within their class. Debugging it, it crashes on trying to set any of those variables through the second class but if I try and do it normally it works fine.
Unless I say otherwise assume I'm talking bout c++. Make things a lot easier :D
Advertisement
Are you certain that length is correct? Your use of it seems a little awkward.
Quote:Original post by jflanglois
Are you certain that length is correct? Your use of it seems a little awkward.


This was the second of a triple-post, recommend continuing discussion in the thread with the first and most replies: clicky

This topic is closed to new replies.

Advertisement