[Qt-interest] can not copy QString and other non understood other c++ error
Andreas Pakulat
apaku at gmx.de
Sun Feb 28 23:59:25 CET 2010
On 28.02.10 23:38:28, Matthias Pospiech wrote:
> 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
> '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
You've made your d-pointer a const object, hence you can't change its
variables, move the const to the other side of the * and read up again
on const-pointer vs. pointer-to-const.
> src\task.cpp:32: error: invalid initialization of reference of type
> 'void*&' from expression of type 'void* const'
Probably the same source.
Andreas
--
Caution: Keep out of reach of children.
More information about the Qt-interest-old
mailing list