Hi,
can someone explain this compiler error below?
#include <QList>
class A
{
public:
A(){ _list = new QList<A*>(); }
~A(){ delete _list;}
int indexOfChild(const A* x) const { return _list->indexOf( x, 0); }
private:
QList<A*> *_list;
};
#include <QList>
class A
{
public:
A(){ _list = new QList<A*>(); }
~A(){ delete _list;}
int indexOfChild(const A* x) const { return _list->indexOf( x, 0); }
private:
QList<A*> *_list;
};
To copy to clipboard, switch view to plain text mode
a.cpp: In member function `int A::indexOfChild(const A*) const':
a.cpp:9: error: invalid conversion from `const A*' to `A*'
a.cpp:9: error: initializing argument 1 of `int QList<T>::indexOf(const T&,
int) const [with T = A*]'
a.cpp: In member function `int A::indexOfChild(const A*) const':
a.cpp:9: error: invalid conversion from `const A*' to `A*'
a.cpp:9: error: initializing argument 1 of `int QList<T>::indexOf(const T&,
int) const [with T = A*]'
To copy to clipboard, switch view to plain text mode
Why takes the conversion from 'const A*' to 'A*' place?
if T = A*
this is
int QList<A*>::indexOf(const A*&, int) const
But A*& ??
References and pointers....
Can someone enligthen me, please?
Thanks,
Moppel
Bookmarks