Split header files
-
Hi, I would like to ask what is the better way to split header file?
I've a class with many QStringList and Enum very long.
This situation makes working in this file difficult and I would like to split in some specific files.
At the moment I've created simple headers file and included in code like this:#include <QObject> #include <QWidget> class MyClass : public QWidget { Q_OBJECT #include "file1.h" #include "file2.h" #include "file3.h" public: explicit MyClass(QWidget *parent = nullptr); ...
I know that it isn't a good practice but at the moment to make my life easier I did so.
I thought maybe the correct way to do this can be create a new class (only header) and inherit this in my class.
But I've a doubt that this too isn't a correct way.
Can you suggest me what can be the correct method to do this?
Thanks. -
@Stefanoxjx Hard to say without knowing what this class is doing.
You should think about your architecture and design. Inheritance and composition can also help to make classes smaller. -
@Stefanoxjx It really depends. Besides inheritance there is also composition. What is better depends on the use case.