I have an abstract class called Screen :
class Screen {
public:
virtual void init() = 0;
virtual void update(float dt) = 0;
virtual void handleInputs(ScreenManager* screenManager) = 0;
virtual void dispose() = 0;
};
And every time I want to create a new Screen I have to: 1 : Create a header file : Ex :
class MenuScreen : public Screen {
public:
void init() override;
void update(float dt) override;
void handleInputs(ScreenManager* screenManager) override;
void dispose() override;
};
2 : Create a cpp file :
void MenuScreen::init() {
}
void MenuScreen::update(float dt) {
}
void MenuScreen::handleInputs(ScreenManager* screenManager) {
}
void MenuScreen::dispose() {
}
Now my problem is I have so many screens , and every time I want to create a new Screen I have to copy and past the header file and all what I have to change is the class name , is there a better way to do that ? am I doing that right ? any help would be appreciated.
CodePudding user response:
You don't have to put all the code in seperate files. If many screens are related or if they are part of a group, you could put them in a single file. You may also use seperate files only for big classes with a lot of code