N
N
Nikolai Shepelev2016-07-09 20:00:15
Programming
Nikolai Shepelev, 2016-07-09 20:00:15

Is it worth it to make a base class in this case and inherit from it?

In general, there are several form classes in Qt like:

//Главное окно
class MainWindow : public QMainWindow
{
//
private:
//
int m, n;
double **data, scaleX, scaleY;
}

//И много других форм, открываемых из главной формы - MainWindow
class OtherWindow : public QMainWindow
{
//
private:
//
int m, n;
double **data, scaleX, scaleY;
}

As you can see, they have common fields - is int m, n; double **data, scaleX, scaleY;it worth making a base class (from the point of view of OOP), from which these fields will be inherited or not? What do you think?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Adamos, 2016-07-09
@venomkol

No, you shouldn't do that.
You break L in SOLID by such inheritance.

D
Daniil Igorevich, 2016-07-09
@Petr_Anisimov

Make it protected on the underlying MainWindow and those fields will be inherited. And why even a separate class for three members?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question