Michael Sullivan wrote:
> I know that a segmentation fault is the equivalent of a null pointer
> exception in Java, but I don't understand why it's happening here.  My
> full code is posted at
> http://www.espersunited.com/~michael/needhelp.txt .  Basically the
> problem is this:
> 
> class battle
> {
>    private:
>       Ally party[4];
> };
> 
> battle::battle()
> {
>    party[0] = Ally("Michael", 10, 7);
>    party[1] = Ally("Amy", 8, 13);
>    party[2] = Ally("Feli", 12, 15);
>    party[3] = Ally("Imp", 9, 4);
> }
> 
> class Ally : public Character
> {
>    public:
>       Ally(){}
>       Ally(char*, long, long);
>       ~Ally();
> };
> 
> Ally::Ally(char* myname, long h, long m) : Character(myname, h, m)
> {
> printf("Arrived in Ally constructor for %s.\n", myname);
> }
> 
> Character::Character(char *myName, long myMaxHP, long myMaxMP)
> {
>    strcpy(name,myName);
>    maxHP = myMaxHP;
>    maxMP = myMaxMP;
> 
>    currentHP = maxHP;
>    currentMP = maxMP;
> }
> 
> Now I've tracked the SegFault down to the battle constructor,
> specifically the line where the 'Amy' Ally is being created.  The
> program enters the Ally constructor, and then SegFaults.  I have very
> little experience with gdb and ddd doesn't work at all.  Can anyone see
> the problem with this?  Am I out of stack space?  Do I need to start
> using the heap?
> 
> 
> 
> 

Maybe a gdb cheat sheet can be of help, they're available for most
popular utils,

We use a4 paper size here:
http://refcards.com/docs/peschr/gdb/gdb-refcard-a4.pdf

http://www.google.co.uk/search?hl=en&q=gdb+refcard&btnG=Google+Search&meta=





[Non-text portions of this message have been removed]

Reply via email to