Returning a pointer from a class
Hey everybody, I am trying to do exactly as my instructor has told me to do on a homework assignment and it just isn't working...
tempStaff = staff
staff = null
BUT, in the other derived class MeleeWarror, the same function needs to return NULL since a MeleeWarrior cannot hold a staff.
So what I'm doing is attempting to use pointers. I have tried:
Staff *tmp = new Staff(*pStaff); // Copy the staff he's holding
delete pStaff; // Delete the staff he's holding
pStaff = NULL; // Get the pointer ready for next staff
return tmp; // Return a copy of the staff
Everything works fine until the very end of the program where it gives me an Unhandled Exception error and crashes...
Any help would be appreciated