Code: Select all
"graphics.h"
class graphics
{
public:
graphics();
~graphics();
void DrawImage();
}
"engine.h"
class engine: public graphics; //that inherit from graphics class
{
public:
engine();
~engine();
}
and the question is, is okay to use the graphics constructor in engine.cpp that includes engine.h that inherit from graphics class instead than in graphics.cpp
Code: Select all
"engine.cpp"
#include "engine.h"
engine::engine(){}
graphics::graphics(){}
Code: Select all
"graphics.cpp"
#include "graphics.h"
void graphics::DrawImage()
{
SDL_BlitSurface(...);
}
Code: Select all
int main(int argc, char *argv[])
{
engine engine;
// son now i call tha function DrawImage() like this
engine.DrawImage();
//instead of
graphics.DrawImage();
so if i do the same thing also with a sound class instead off calling each function from its respective class i call them from my engine class that inherit them.
and is there any way to have in the engine class a funtion called for example "StartEngine()" that initialize al the constructors from my other classes like sound, graphics input etc ?? thanx for your time