当前位置: 技术问答>linux和unix
QT中的多线程的问题
来源: 互联网 发布时间:2015-04-02
本文导语: 请问下面的代码为何编译会报如下的错: .h 文件 #include class MyThread : public QThread { public: MyThread{} void run(); ~MyThread{} }; .cpp文件 #include "thread.h" void MyThread::run() { ...
请问下面的代码为何编译会报如下的错:
.h 文件
#include
class MyThread : public QThread
{
public:
MyThread{}
void run();
~MyThread{}
};
.cpp文件
#include "thread.h"
void MyThread::run()
{
}
make
usr/lib/qt3-gcc3.2/bin/uic form1.ui -o form1.h
g++ -c -pipe -Wall -W -I/usr/include/fontconfig -I/usr/include/Xft2 -O2 -march=i386 -mcpu=i686 -fno-use-cxa-atexit -fno-exceptions -DQT_NO_DEBUG -I/usr/lib/qt3-gcc3.2/include -I/usr/lib/qt3-gcc3.2/mkspecs/default -o main.o main.cpp
g++ -c -pipe -Wall -W -I/usr/include/fontconfig -I/usr/include/Xft2 -O2 -march=i386 -mcpu=i686 -fno-use-cxa-atexit -fno-exceptions -DQT_NO_DEBUG -I/usr/lib/qt3-gcc3.2/include -I/usr/lib/qt3-gcc3.2/mkspecs/default -o thread.o thread.cpp
In file included from thread.cpp:1:
thread.h:3: parse error before `{' token
thread.cpp:3: invalid use of undefined type `class MyThread'
thread.h:3: forward declaration of `class MyThread'
make: *** [thread.o] Error 1
.h 文件
#include
class MyThread : public QThread
{
public:
MyThread{}
void run();
~MyThread{}
};
.cpp文件
#include "thread.h"
void MyThread::run()
{
}
make
usr/lib/qt3-gcc3.2/bin/uic form1.ui -o form1.h
g++ -c -pipe -Wall -W -I/usr/include/fontconfig -I/usr/include/Xft2 -O2 -march=i386 -mcpu=i686 -fno-use-cxa-atexit -fno-exceptions -DQT_NO_DEBUG -I/usr/lib/qt3-gcc3.2/include -I/usr/lib/qt3-gcc3.2/mkspecs/default -o main.o main.cpp
g++ -c -pipe -Wall -W -I/usr/include/fontconfig -I/usr/include/Xft2 -O2 -march=i386 -mcpu=i686 -fno-use-cxa-atexit -fno-exceptions -DQT_NO_DEBUG -I/usr/lib/qt3-gcc3.2/include -I/usr/lib/qt3-gcc3.2/mkspecs/default -o thread.o thread.cpp
In file included from thread.cpp:1:
thread.h:3: parse error before `{' token
thread.cpp:3: invalid use of undefined type `class MyThread'
thread.h:3: forward declaration of `class MyThread'
make: *** [thread.o] Error 1
|
上面不是说了吗,没有定义mythread1
|
MyThread{}
~MyThread{}
楼主仔细看看,哈哈