Confused While Debugging
My program kept closing down unexpectedly so I ran the debugger (in Xcode) and found an EXC_BAD_ACCESS when dealing with the following code:
I can't figure out what's so wrong with this code. Any suggestions?
Code:
class Weapon
{
public:
void AddFireTimer(float t) { fireTimer += t; }
private:
float fireTimer;
};I can't figure out what's so wrong with this code. Any suggestions?
that doesn't look like executable code, except for the
void AddFireTimer(float t) { fireTimer += t; } part.
my guess is that your Weapon object is invalid.
do you have a stack trace?
void AddFireTimer(float t) { fireTimer += t; } part.
my guess is that your Weapon object is invalid.
do you have a stack trace?
I looked through more of my code and found out my problem.
I have a player class containing four weapons (from the above class). I was trying to assign values to these weapons by using the = operator which failed horribly because I assume it was trying to create a pointer to a temporary object which was erased at the end of my program's init() function. I found a way around that so that I can now directly edit those weapons from the init() function without causing more errors.
Guess I should look harder before posting (as I solved my own problem) but I spent the better part of last evening working on this and didn't see the problem.
I have a player class containing four weapons (from the above class). I was trying to assign values to these weapons by using the = operator which failed horribly because I assume it was trying to create a pointer to a temporary object which was erased at the end of my program's init() function. I found a way around that so that I can now directly edit those weapons from the init() function without causing more errors.
Guess I should look harder before posting (as I solved my own problem) but I spent the better part of last evening working on this and didn't see the problem.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Confused as to array behaviour | kendric | 3 | 2,078 |
Mar 14, 2009 05:26 PM Last Post: kendric |
|
| Debugging Help - Game Won't Display | Rasterman | 6 | 2,859 |
Dec 14, 2007 08:10 AM Last Post: Rasterman |
|
| Confused with array-ness | Tobs_ | 4 | 2,944 |
Aug 12, 2007 05:37 PM Last Post: JeroMiya |
|
| debugging framework source in XCode | squozebrain | 3 | 4,119 |
Aug 16, 2006 05:47 PM Last Post: squozebrain |
|

