operator=new ClassObj() is not recognized
i tried to make inline class using following header:
Code:
#include <QString>
#include <QFile>
#include <QThread>
class _File
: public QFile
{
Q_OBJECT
public:
_File();
_File(const _File& file);
public:
FThread();
FThread(_File *par);
virtual void run();
FThread& operator=(const FThread& other);
private:
_File *parentFile;
};
void setProgress(qint64 val);
...//goes on
and i am trying to create new instance of FThread in other file main.cpp
fileObj->fthread=new _File::FThread(fileObj);
and its giving me error as it doesn't recognize =new operator...it works fine if i dont add "new" keyword, but i need to create new instance in order to achieve my goal...
i am getting following error
../engine/main.cpp:22: error: no match for ‘operator=’ in ‘fileObj->_File::fthread = (operator new(12u), (<statement>, ((_File::FThread*)<anonymous>)))’
../engine/_file.h:25: candidates are: _File::FThread& _File::FThread::operator=(const _File::FThread&)
please help
any help please?
Re: operator=new ClassObj() is not recognized
it looks like fileObj->fthread is a const - or probably not a pointer, but a value variable.
Re: operator=new ClassObj() is not recognized
QThread is also a QObject so providing an assignment operator for it yields the same consequences as for QFile which I mentioned in another one of your threads. Based on how you are using this class I can tell you upfront there is no way you are going to use this assignment operator properly so you may as well remove it. Of course this has nothing to do with your current problem.