Ok so ive got a class called Imagehandler, this has a few functions, the main 2 giving me trouble are the "loadSprite" function and the "createBuffer" function. The loadSprite(BITMAP* x, const char* Filename, takes those parameters, the create buffer take the parameters createBuffer(BITMAP* x, int Screenwidth, int Screenheight). I create 2 bitmaps like this for the "BITMAP x" parameter :
BITMAP* Buffer;
BITMAP* Player;
I use them in the functions, yet it tells me they are not intialized? how am i supposed to initialize them? also inside the functions they both are set to something "Initialized" as its put, like the Buffer is this :
x(Which is the Buffer) = create_bitmap(int Screenwidth, int Screenheight) and its pretty much the same for the Player bitmap. How do i stop getting theese warning telling me to initialize the bitmaps? btw my error code is c4700 - uninitialized local varibal '(variable name) ' Used.
Any help would be amazing, thanks!
class BITMAP
{
public:
BITMAP();
~BITMAP();
};
BITMAP::BITMAP()
{
}
BITMAP::~BITMAP()
{
}
class Imagehandler
{
public:
Imagehandler();
~Imagehandler();
void loadSprite(BITMAP** x, constchar* Filename);
void createBuffer(BITMAP** x, int Screenwidth, int Screenheight);
};
Imagehandler::Imagehandler()
{
}
Imagehandler::~Imagehandler()
{
}
void Imagehandler::loadSprite(BITMAP** x, constchar* Filename)
{
*x = new BITMAP(); // allocate BITMAP on the heap at address specified at: *x
}
void Imagehandler::createBuffer(BITMAP** x, int Screenwidth, int Screenheight)
{
*x = new BITMAP(); // allocate BITMAP on the heap at address specified at: *x
}
int main()
{
Imagehandler Handler; // handler on the stack
BITMAP* Buffer(NULL), *Player(NULL); // we are creating BITMAP's on the heap:
// create BITMAP's on the heap:
Handler.createBuffer(&Buffer, 200, 300);
// to do - delete any memory allocated on the heap:
if (Buffer)
delete Buffer;
if (Player)
delete Player;
return 0;
}