-
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QDebug> namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private slots: void on_ok_button_clicked(); void on_cancel_button_clicked(); private: Ui::MainWindow *ui; };
What is meant by explicit MainWindow(QWidget *parent=0)?
why we write Qwidget *parent=0?
Is itokay if we dont write explicit? -
-
When you write:
explicit MainWindow(QWidget *parent);
you will have to assign a parent, because it expects an argument.
But when you write:explicit MainWindow(QWidget *parent = 0);
you don't have to assign a parent, as it has already a default argument.
As for the second question, perhaps this gives you some insight?
https://msdn.microsoft.com/en-us/library/wwywka61.aspx