PDA

View Full Version : Using QVector properly. Error compilation.



robgeek
12th May 2015, 00:41
Good evening!

What is wrong with the code bellow? "Number" is a class which has an constructor Number(int i, int j).

QList< QVector< Number > > Lottery::patternList(QList< QVector< Number > > pl, int array[], int size)
{
QVector<Number> first;

if( pl.size( ) )
{
//Not implemented.
}
else
{
for(int i = 0; i < size; i++)
if(array[i] != 0)
first.push_back( Number((i + 2), array[i]) );

pl.push_back( first );
}
}

Error message:

C:\Qt\5.4\mingw491_32\include\QtCore\qvector.h:281 : error: no matching function for call to 'Number::Number()'
new (from++) T();
^

Thanks!

jefftee
12th May 2015, 03:07
Hi, types stored in Qt containers must be assignable types. They must provide a default contructor, a copy constructor, and an assignment operator.