Meaning of (QWidget *parent = 0) in constructor MyClass(QWidget *parent = 0);
c++, constructor, qt
Solution
`MyClass(QWidget *parent = 0)` defines a constructor that can take a `QWidget*`.
You might be confused at the `= 0` part, which is C++ syntax for default arguments. Default arguments allow you to use the function without having to specify that particular argument. In the case of this, you could call this constructor like this:
mc = MyClass();
And this is equivalent to calling:
mc = MyClass(0); // or MyClass(NULL)
And that means that `MyClass` object will have no parent `QWidget`, because `= 0` means the parent is a null pointer.
Problem
just a part of a usual structured class in Qt: ``` class MyClass : public QWidget { Q_OBJECT public: MyClass(QWidget *parent = 0); . . . } ``` Looking at the constructor I don't understand the meaning of the parameter `(QWidget *parent = 0)` ? What does this mean? greetings