I got one class named FaultsTablemanager, it has two constructors:
class FaultsTableManager : public QObject
{
Q_OBJECT
public:
FaultsTableManager(MainWindow* mainW,
QMutex* mu,
QWidget* parentPa,
QTableWidget* tabA,
QRadioButton* sel1,
QRadioButton* sel2,
QQueue<RDIU*>* que,
QTableWidget* tabDe,
QWidget* parentDe,
QLabel* nameLab,
QLabel* timeLab);
FaultsTableManager(MainWindow* mainW,
QMutex* mu,
QWidget* parentPage1,
QTableWidget* tabA,
QRadioButton* sel1,
QRadioButton* sel2,
QList<RDIU*>* list1,
QList<RDIU*>* list2,
QTableWidget* tabDe,
QWidget* parentDe,
QLabel* nameLab,
QLabel* timeLab);
...
}
I want to reuse the first constructor in the second one like this:
FaultsTableManager::FaultsTableManager(MainWindow* mainW,
QMutex* mu,
QWidget* parentPa,
QTableWidget *tabA,
QRadioButton *sel1,
QRadioButton *sel2,
QList<RDIU*> *list1,
QList<RDIU*> *list2,
QTableWidget* tabDe,
QWidget* parentDe,
QLabel* nameLab,
QLabel* timeLab)
{
FaultsTableManager(mainW,
mu,
parentPa,
tabA,
sel1,
sel2,
NULL,
tabDe,
parentDe,
nameLab,
timeLab);
// table = tabA;
queue = NULL;
list = list1;
errList = list2;
}
But if I left the line of code table = tabA;
commented, the member table
will not be initialized(cannot be used later).
So I think the call of the first constructor will not operate on the object, and only new another object which is not stored in my constructor function.
But I've saw the call of base calss's constructor in subclass's and it operates on the same object which is the reason I use this method.
So is it possible for me to reuse constructor A
in constructor B
? if not, it seems too redundant and I believe there is a better way to solve this redundance.