[Qt-interest] can not copy QString and other non understood other c++ error
Matthias Pospiech
matthias.pospiech at gmx.de
Sun Feb 28 23:38:28 CET 2010
This code does not compile:
class TaskPrivate
{
public:
TaskPrivate(Task * parent)
: taskHandle(0)
, aiChannels(AIChannels(parent))
{}
AIChannels aiChannels;
TaskHandle taskHandle;
QString taskName;
};
Task::Task(QObject *parent, QString taskName /* = "" */)
: QObject(parent)
, d(new TaskPrivate(this))
{
d->taskName = taskName;
TaskHandle & taskHandle = d->taskHandle;
int error = DAQmxCreateTask (taskName.toLatin1(), &taskHandle);
}
with these errors:
src\task.cpp: In constructor
'TaskPrivate::TaskPrivate(NationalInstruments::DAQ::Task*)':
src\task.cpp:21: warning: 'TaskPrivate::taskHandle' will be initialized
after
src\task.cpp:17: warning: 'NationalInstruments::DAQ::AIChannels
TaskPrivate::aiChannels'
src\task.cpp:9: warning: when initialized here
src\task.cpp: In constructor
'NationalInstruments::DAQ::Task::Task(QObject*, QString)':
src\task.cpp:31: error: passing 'const QString' as 'this' argument of
'QString& QString::operator=(const QString&)' discards qualifiers
src\task.cpp:32: error: invalid initialization of reference of type
'void*&' from expression of type 'void* const'
src\task.cpp:33: warning: unused variable 'error'
and I have no idea why. Can anybody help me out?
Matthias
More information about the Qt-interest-old
mailing list