Confused While Debugging

Sage
Posts: 1,066
Joined: 2004.07
Post: #1
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:

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?
Quote this message in a reply
Hog
Member
Posts: 151
Joined: 2002.09
Post: #2
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?
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #3
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.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Confused as to array behaviour kendric 3 2,327 Mar 14, 2009 05:26 PM
Last Post: kendric
  Debugging Help - Game Won't Display Rasterman 6 3,288 Dec 14, 2007 08:10 AM
Last Post: Rasterman
  Confused with array-ness Tobs_ 4 3,244 Aug 12, 2007 05:37 PM
Last Post: JeroMiya
  debugging framework source in XCode squozebrain 3 5,835 Aug 16, 2006 05:47 PM
Last Post: squozebrain