|
new and delete commands
Hey
I am trying to use the 'new' and 'delete' with a class with a linked list. The problem is this:
Well I tried to use the new command with a very simple class with no linked list and it still crashed. So I know it is not the class that is messed up. (Well I am 90% sure) Does anyone know what I am doing wrong? Thanks...
[/source]
Edited by - JSCFaith on May 13, 2001 1:26:38 AM
May 13, 2001 12:47 AM
assuming your compiler isn''t buggy, look closely at your constructors and make sure you aren''t dereferencing NULL or uninitialized pointers. Usually it''s something like that...
Well I looked at my constructor and it looks fine, but to be safe I just commented out all the linked list code in both Bullet and GameObject and it still crashed. Any other ideas?
One more thing, what do you mean by Dereferencing NULL or uninitialized pointers.
Well, thanks.
Later.
One more thing, what do you mean by Dereferencing NULL or uninitialized pointers.
Well, thanks.
Later.
Dereferencing a null pointer:
99% of access violations come from:
- dereferencing null pointer
- dereferencing uninitialized pointer
- dereferencing deleted pointers (will point do data of 0xDDDDDDDD in debug builds of MSVC)
- exceeding array bounds
struct Something{ int member;};int main (){ Something *nothing = NULL; // nothing is null pointer return nothing->member; // run-time error--access violation};
99% of access violations come from:
- dereferencing null pointer
- dereferencing uninitialized pointer
- dereferencing deleted pointers (will point do data of 0xDDDDDDDD in debug builds of MSVC)
- exceeding array bounds
Well,you might want to post the code for your Asteroid. Is your asteroid a seperate class, or is it a struct?
Edem Attiogbe
Edem Attiogbe
Edem Attiogbe
Oops, sorry. That is supposed to say:
Edited by - JSCFaith on May 13, 2001 6:18:17 PM
|
Edited by - JSCFaith on May 13, 2001 6:18:17 PM
May 14, 2001 12:03 AM
If all reasoning fails, you can try to trace your program in a debugger or insert some diagnostic prints into your code to find out where it''s crashing. narrowing down the possibilities of what went wrong helps A LOT.
anonymous guy
anonymous guy
Yeah, I was thinking of doing that and I think I will. Well thanks for the help guys.
Later and Thanks..
Later and Thanks..
![](smile.gif)
Maybe try posting your GameObject constructor too if you still can''t find the problem. It might not actually be in the constructor for Bullet.
If you are using MSVC6.0 try running it in debug mode, if you get an access violation at offset 0x00000005, or something like that, then your probably trying to use something before its initialized
In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement