Writing to a class pointer gives me an access violation error
<p>Please view this image of the crash after I choose to debug it in MVS2010:
<a href="http://i48.tinypic.com/dr8q9u.jpg" rel="nofollow">http://i48.tinypic.com/dr8q9u.jpg</a></p>

<p>Here's the Game.h header that shows the Game class structure, and in the picture you will see the offending method that's causing the access violation (<code>setBot(botInfo * b)</code>).</p>

<pre><code>class botInfo; // Forward declaration

class Game {
 int gameState;
 int flagDropTime;
 botInfo * bot;
public:
 Game();
 ~Game(void);
 void startGame();
 void gameOver(int victoriousTeam);
 void resetBall();
 void hideBall();
 int getState();

 void setBot(botInfo * bot);
 botInfo * getBot();
};
</code></pre>

<p>From an instance of botInfo (another class) I'm calling a function with this code, 
(Game _dsbTrench is a member variable of the botInfo instance).</p>

<pre><code>botInfo * botPointer = this;
_dsbTrench-&gt;setBot(botPointer);
</code></pre>

<p>Problem is, whenever I call this it causes an exception:
Unhandled exception at 0x72332569 (PubBot.dll) in MERVBot.exe: 0xC0000005: Access violation writing location 0xcdcdcdd5.</p>

<p>So whats the cause of this error? And how can I fix it?</p>

<p>Thanks.</p>
