C++ Variable not being instantiated properly
<pre><code>Sprite1 *test = new Sprite1(450, 450, "enemy.bmp", *screen);
    test-&gt;DrawJon();
    SDL_Delay(1000);
    test-&gt;MoveJon(20,20);
</code></pre>

<p>I am getting a runtime error on line #2. It says access violation at 0x0</p>

<p>Sprite1 is a class I have defined and DrawJon() and MoneJon() in the class. This syntax is ok with the compiler but fails in runtime.</p>

<p>Sprite1.cpp</p>

<pre><code>#include "Sprite1.h"

Sprite1::Sprite1(int posX, int posY, std::string imagePath, SDL_Surface screen) :     PosX(posX), PosY(posY), ImagePath(imagePath), Screen(screen)
{
void DrawSprite1Jon( int x, int y, SDL_Surface *sprite, SDL_Surface *screen );
void DrawJon();
void MoveJon(int xDist, int yDist);
}

void Sprite1::DrawSprite1Jon( int x, int y, SDL_Surface *sprite, SDL_Surface *screen )
{
//Make a temporary rectangle to hold the offsets
SDL_Rect offset;

//Give the offsets to the rectangle
offset.x = x;
offset.y = y;

//Blit the surface
SDL_BlitSurface( sprite, NULL, screen, &amp;offset );

SDL_UpdateRect(screen, 0, 0, 0, 0);
}

void Sprite1::DrawJon()
{
#pragma region Char to String Conversion

string ImagePath;
char * writable = new char[ImagePath.size() + 1];
copy(ImagePath.begin(), ImagePath.end(), writable);
writable[ImagePath.size()] = '\0';

#pragma endregion

temp = SDL_LoadBMP(writable);
sprite = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);

// free the string after using it
delete[] writable;

DrawSprite1Jon(PosX, PosY, sprite, screen);
}
</code></pre>

<p>Sprite1.h</p>

<pre><code>#include &lt;string&gt;
#include &lt;SDL.h&gt;
#include "Functions.h"

using namespace std;

class Sprite1
{
private:
    int PosX;
    int PosY;
    int xDist;
    int yDist;
    string ImagePath;
    SDL_Surface Screen;
    SDL_Surface *temp, *sprite, *screen;

public:
    Sprite1(int PosX, int PosY, string ImagePath, SDL_Surface Screen );
    void DrawSprite1Jon( int x, int y, SDL_Surface *sprite, SDL_Surface *screen);
    void DrawJon();
    void MoveJon(int xDist, int yDist);
};
</code></pre>

<h1>EDIT:</h1>

<p>upon further investigation, it is this line</p>

<pre><code>DrawSprite1Jon(PosX, PosY, sprite, screen);
</code></pre>

<p>That is failing in the DrawJon()</p>
