To keep this simple I will show part of the "base class, and a derived class".
I essentially NEED to have the ; member variable of the base class get the value from the derived class.
Hopefully the code will make it clear what I'm trying to do.
(I left out a ton of code, and just reference the part that wont work.)
Assuming I did everything else right, how do I get the member variable of the base class to get the .bmp indicated in the derived class?)
THANKS! ------LOOK BELOW
Code:
-----------------------CODE-----------…
----------BASE CLASS----------
class cWidget
{
public:
SDL_Surface *widget;
cWidget();
}
----------DERIVED CLASS----------
class bluecWidget:public cWidget
{
public:
bluecWidget();
bluecWidget(SDL_Surface *widget);
};
----------------------THE FOLLOWING IS IN THE .CPP FILE-----------------
-----------BASE CLASS--------
cWidget::cWidget()
{
//VARIABLE NOT REFERENCED HERE
}
-----------BASE CLASS FUNCTION---------
void cWidget::apply_surface( int x, int y)
{
//Blit
SDL_BlitSurface( widget, NULL, screen, &offset );
}
--------DERIVED CLASS-----------
bluecWidget::bluecWidget():cWidget()
{
}
bluecWidget::bluecWidget(SDL_Surface *widget)
{
widget = SDL_LoadBMP("Game_blue.bmp");
}