Skip to main content
gamedev.net
🔒 Locked

phantom class error

Started by Neen10do May 17, 2003 at 11:16 PM 9 replies 400+ views
Original Post
Neen10do
Neen10do
im working on a creating a class for my levels, so i can lod the level data from files created with my level editor, but im running into problems. here is my cLevel class, it is very basic and does nothing right now: this is my clevel.h source
  
//cLevel Header File


//INCLDUES////////////////////////////

#include "cSprite.h"
//////////////////////////////////////


//Level Class/////////////////////////

class cLevel
{
public:

	//Data Members//////////////////

	//Background

	char*			background_file;
	cSprite			background;
	////////////////////////////////


	//Constructor and Destructor////

	cLevel();
	~cLevel();
	////////////////////////////////


};
//////////////////////////////////////

  
and this is my clevel.cpp source
  
//CLEVEL IMPLEMENTATION FILE


//INCLUDES/////////////////////

#include "cLevel.h"
///////////////////////////////


//Constructor and Destructor///////////

cLevel::cLevel()
{

}

cLevel::~cLevel()
{

}
///////////////////////////////////////

  
when compiling, i dont get any errors. however, when i add a cLevel object to my cMainGame Class: cLevel CurrentLevel; it compiles, and runs, but when i exit the program, i get an error, possibly like a bad pointer error or something. however, when i debug, it doesn''t go to it, it gives me an access violation error. so i say "ok, the class is fucked up, let me get rid of it". so i take it out of my project, unlink it, and get rid of the object out of my game class. THE ERROR STAYS WHEN THE CLASS WAS GONE. before the level class was there it compiled and ran fine. as soon as i put it in i got the crash error when the program exited, and then it woudln''t go away. i loaded a backup workspace and the problem was gone... so i tried it again and the same thing happened, whats the problem!?!? im going nuts. ---------------------- i code therefore i am. Aero DX - Coming to a bored Monitor near you!
----------------------i code therefore i am.Aero DX - Coming to a bored Monitor near you!
Sneftel
Sneftel
Try cleaning and recompiling.

Also, are you sure the class is causing the error? In my experience, nine programmers out of ten who say "I just did x, and it crashed" actually did x, y, z, and q.


How appropriate. You fight like a cow.
Neen10do
Neen10do
the thing is that in cases like this it would usually show me the bad pointer, but it doesn''t.

furthermore, if you look at the code, there arnt any pointers! what would be the problem. ive only done what i said i did.

----------------------
i code therefore i am.

Aero DX - Coming to a bored Monitor near you!
----------------------i code therefore i am.Aero DX - Coming to a bored Monitor near you!
Neen10do
Neen10do
ive worked on it for hours, and i still cant get it to work. it would stop working and i would get this pointer error thing after doing nothing, it happens at random, and when it does, i cant get rid of it no matter what i do. the only solution i can think of is zipping it, and allowing you guys to look at it. its the whole project, so its kinda big (8mb) but im sure you guys with cable wont have a problem. i would REALLY REALLY appreicaite it if you guys can take a look, i am really stumped.

click here, its tripod, might have to right click save as

thank you guys!

----------------------
i code therefore i am.

Aero DX - Coming to a bored Monitor near you!
----------------------i code therefore i am.Aero DX - Coming to a bored Monitor near you!
Neen10do
Neen10do
anyone? for the love of god, allah, muhammad, or whoever applies!

----------------------
i code therefore i am.

Aero DX - Coming to a bored Monitor near you!
----------------------i code therefore i am.Aero DX - Coming to a bored Monitor near you!
Neen10do
Neen10do
FOR THE LOVE OF GOD!!! I NEED SOME HELP!!!!!!! THIS IS REALLY FRUSTRATING AND WEIRD!!!!!!!!!!!

it seems now that anytime i had any class as a member of my cMainGame class it crashes!!! WTF!!!!!!!!

----------------------
i code therefore i am.

Aero DX - Coming to a bored Monitor near you!
----------------------i code therefore i am.Aero DX - Coming to a bored Monitor near you!
Sneftel
Sneftel
When you run it in the debugger, what line is the access violation on?


How appropriate. You fight like a cow.
Neen10do
Neen10do
it wont tell me

----------------------
i code therefore i am.

Aero DX - Coming to a bored Monitor near you!
----------------------i code therefore i am.Aero DX - Coming to a bored Monitor near you!
superpig
superpig
I''m going to assume you''re using MSVC.

Run the debugger, and when it hits the access violation it should give you a little dialog box. Click OK, and then choose ''Call Stack'' from the Debug windows in the View menu.

You should see a window which shows where the program counter is, with a hierarchy of functions - the top function is where it is at the moment, and the bottom function is your WinMain (or the one that calls WinMain). The top ones will often have names like KERNEL32, but double-click on the first name in the list that you recognise as being your own function.MSVC should jump to the line of code which is resulting in the problem.

The other thing you should do is have the Output window open in Debug mode - if you''re corrupting the heap, you won''t see it until the program exists, and the error message will be in that Output window.

If you could do both of those and tell us what you get (if there are no functions you recognise in the call stack, for example, of if a Heap error message is being displayed in the Output window), we can help you better.

Superpig
- saving pigs from untimely fates, and when he''s not doing that, runs The Binary Refinery.
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
Sneftel
Sneftel
There should really be a MSVC debugger tutorial in A&R, if there''s not one there already.


How appropriate. You fight like a cow.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.