You are not logged in.


Saturday, January 21st 2012, 11:43am

Noob question;

What is the difference between

MyThread::MyThread(QObject *parent) :
c(0) //this is defined in the mythread.h as int c;


MyThread::MyThread(QObject *parent) :

both seems to work fine


Saturday, January 21st 2012, 1:04pm

the difference is that if you have a reference member variable, you MUST initialise it like in the first example. the latter will be compiler error.

If you have members that do not have default ctor, then the second example will also fail.

The difference is that the second one constructs c, then assigns it, whereas the first only constructs it.
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.