just give it a empty default constructor...
and remove the '0' in log(0,...); make it at least 1
just give it a empty default constructor...
and remove the '0' in log(0,...); make it at least 1
The compiler generates a default constructor for your struct (just like with classes) if it is not written manually.
The problem with your case is that QVector's constructor looks like this:
Qt Code:
To copy to clipboard, switch view to plain text mode
It means you have to pass value by reference. The way you do this, will not return a reference.
That's why you need to do
Qt Code:
M::M() { LOGRECORD logRec; log(1, logRec); }To copy to clipboard, switch view to plain text mode
I'm a rebel in the S.D.G.
QVector has the following constructor
Are you saying that I cannot do this
Qt Code:
To copy to clipboard, switch view to plain text mode
?????
I'm a rebel in the S.D.G.
there is a difference in declaration and defination...
when a constructor is called, the members are defined... the member's constructors are called
automatically... if you want to initialize members via their cotr.. then u have to use initializer list..
Qt Code:
myclass { myclass() : v(2)//here it is ok at constructor initializer list { } myclass() { v(2);//you cannnot do it this way... } QVector v; }To copy to clipboard, switch view to plain text mode
your code did the same thing... rite??
Qt Code:
M::M() { LOGRECORD logRec; log(1, logRec);//ERROR }To copy to clipboard, switch view to plain text mode
hope i am clear now!!
Last edited by nish; 8th July 2009 at 16:02.
Oh, got it what you mean.
I'm a rebel in the S.D.G.
Bookmarks