Is it necessary to initialize member variables with nullptr or Q_NULLPTR in header files? If yes, why is it so required, when I do proper initialize it the ctor initialization list.
in MyDialog.h,
QDialog* m_Dialog = Q_NULLPTR;
and in MyDialog.cpp...I do
MDialog()::MDialog()
: QDialog()
, m_Dialog(new QDialog())
{
}
And in destructor, I do proper delete n setting it to nullptr.
Why is the below required?
QDialog* m_Dialog = Q_NULLPTR;
It is not required that you use
QDialog* m_Dialog = Q_NULLPTR;
to initialize the member variable.
The above syntactic form is useful when there are many constructors in which you'll want to initialize the member variable with the same value. It reduces duplicate code.
If your class has the only constructor that you posted, you could leave the member variable declaration as
QDialog* m_Dialog;
without adversely affecting your program.