   Strange crash when defining another variable
  Hi, I have a class named Arahnova where in my game is the spider boss.Arahnova.h#ifndef ARAHNONA_H#define ARAHNOVA_H#include <hge.h>#include <hgeResource.h>#include <hgeAnim.h>#include "direction.h"#include "Point2D.h"#include "Player.h"#include "WebBall.h"#include <boost/shared_ptr.hpp>class Arahnova;namespace ArahnovaState{class State{State(const State &);State &operator = (const State &);// variablesArahnova *const ptr;protected:Arahnova *getPtr() const { return ptr; }bool WebBallFired() const;void ResetWebBallPosition();static HSTREAM webBallSound;static uint instances;HCHANNEL webBallChannel;public:State(Arahnova *arahnova);virtual ~State();virtual void Update(const float dt) = 0;virtual void SetAnimation() = 0;virtual std::string ClassName() const = 0;};class Stand : public State{float oscillationTime;public:Stand(Arahnova *arahnova);void Update(const float dt);void SetAnimation();std::string ClassName() const { return "Arahnova_Stand"; }};class Attack : public State{static const float WEB_BALL_VEL, // velocity   WEB_BALL_ACCEL; // accellerationpublic:Attack(Arahnova *arahnova);void Update(const float dt);void SetAnimation();std::string ClassName() const { return "Arahnova_Attack"; }};class CollectPlayer : public State{public:CollectPlayer(Arahnova *arahnova);void Update(const float dt);void SetAnimation();std::string ClassName() const { return "Arahnova_CollectPlayer"; }};}class Arahnova{friend class ArahnovaState::State;friend class ArahnovaState::Stand;friend class ArahnovaState::Attack;friend class ArahnovaState::CollectPlayer;static const float MAX_WEB_LENGTH,   ANGULAR_VELOCITY,   MAX_VISION_DISTANCE;enum { X, Y };struct Vision{Point2D center;float radius;} vision;Point2D position, velocity, accelleration;// state array (all states are in there)std::auto_ptr <ArahnovaState::State> state[2];ArahnovaState::State *currentState;direction lookingDirection;hgeAnimation *anim;std::auto_ptr <WebBall> webBall;Player *player;HGE *hge;hgeResourceManager *const resourceManager;float timePassed;const float angularVelocity;public:Arahnova(hgeResourceManager *_resourceManager, float _x, float _y, Player *_player);~Arahnova();void Render();void Update();float x() const { return position.x; }float y() const { return position.y; }float w() const { return anim->GetWidth(); }float h() const { return anim->GetHeight(); }void x(const float newX) { position.x = newX; }void y(const float newY) { position.y = newY; }void setVelocityX(const float val) { velocity.x = val; }void setVelocityY(const float val) { velocity.y = val; }void setAccellerationX(const float val) { accelleration.x = val; }void setAccellerationY(const float val) { accelleration.y = val; }direction LookDirection() const { return lookingDirection; }Point2D getVelocity() const { return velocity; }Point2D getAccelleration() const { return accelleration; }float DistanceFromPlayer();WebBall *getWebBall() const { return webBall.get(); }bool WebBall_IsAlive() const;float WebBall_x() const;float WebBall_y() const;float WebBall_w() const; // if ptr is NULL returns 0float WebBall_h() const; // if ptr is NULL returns 0};#endifThe behavior of Arahnova is handled by the ArahnovaState::State class, which serves as a state of it. When the behavior (state) must be changed, the currentState pointer changes.ArahnovaState::State class had two inherited classes, ArahnovaState::Stand and ArahnovaState::Attack. So I defined an array(or size 2) of std::auto_ptr pointers to ArahnovaState::State so that currentState points to one of those, so I wouldn't have to allocate new memory every time the state changes (which happens very frequently).So in Arahnova's constructor I wrote this code:state[0].reset(new ArahnovaState::Stand(this));state[1].reset(new ArahnovaState::Attack(this));currentState = state[0].get();(ArahnovaState::State takes an Arahnova pointer as a parameter in its constructor, to operate on, so the this pointer is passed in.Everything worked fine until I decided to include one more state, ArahnovaState::CollectPlayer. So I changed the size of the array to 3, and compiled (WITHOUT WRITING ANY ADDITIONAL CODE). It crashed with this message.I changed the size back to 2 and defined a variable int i; in the class, without assigning a value to it. It crashed again. I found that it crashes whatever I do, like it's not letting define another variable in the class!Please Help :)   
  If you step through it with the debugger, does it always crash at the same place?Also, try doing a clean build of the entire project.   ;Quote:Original post by sheep19So in Arahnova's constructor I wrote this code:Does the reset method invoke any methods on its argument, or does it just store it somewhere for later processing?   ;  I rebuilt and it works now!   