Home > Back-end >  To ask a question the pointer to the constructor argument
To ask a question the pointer to the constructor argument

Time:09-20

I want to know the code QWidget * parent=0 is what meaning, and if the single from the c + +=0 is represent? Why not=0 if constructed object without parameters (such as MainWindows mw) would say there is no matching constructor, and added a=0 will not appear this error?

 # # ifndef MAINWINDOW_H 
# define MAINWINDOW_H

#include

The namespace Ui {
The class MainWindow.
}

The class MainWindow: public QMainWindow
{
Q_OBJECT

Public:
Explicit MainWindow (QWidget * parent=0);
~ MainWindow ();

Private:
Ui: : MainWindow * Ui;
};

# endif//MAINWINDOW_H

CodePudding user response:

Default constructor parameters, if you omit parameter, equal with the default value as a parameter,

CodePudding user response:

By default the null pointer
  • Related