Explain me how this constructor works!
-
this is the constructor:
ClientServices::ClientServices(const QString hostAddress, int portNumber) : QObject (),m_nNextBlockSize(0) {
I would like to understand after colon.(m_nNextBlockSize(0) it's declared on the header file like this "quint16 m_nNextBlockSize;" why?
can you give me some tips about the type of constructors? Not having much experience I need help i don't understend them very well..
-
Hi
After the ":", its actually an initialization list
https://en.cppreference.com/w/cpp/language/initializer_listbasically its another syntax for
m_nNextBlockSize =0;so its a way to set member variables during construction.
-
@LeLev said in Explain me how this constructor works!:
@Nio74 hi, the constructor will initialize that quint16 m_nNextBlockSize declared in the header
why do you decare(quint16 m_nNextBlockSize ) in the constructor when it's already declared in the header file?