I have a problem with class multithreading in c++ my code is the next but i have many error and i dont know why ... i hope that one person can help me and explain my error. Ty
- Le fichier Task.hpp : - #ifndef TASK_HPP_ #define TASK_HPP_ #include "thread.hpp" class Task { public: Task(int id); virtual ~Task(); void setThread(Thread *_thread); void virtual work(); protected: int taskID; Thread *thread; }; #endif /* !TASK_HPP_ */
Le fichier Thread.hpp :
#ifndef THREAD_HPP_
#define THREAD_HPP_
#include "pool.hpp"
class Thread
{
    public:
        Thread();
        void setPool(Pool *_pool);
        void setId(int _id);
        int getId();
        void start();
        void terminate();
        static void* work(void *param);
    private:
        pthread_t pthread;
        Pool *pool;
        int id;
        bool isWorking = false;
};
#endif /* !THREAD_HPP_ */
Le fichier Pool.hpp :
#ifndef POOL_HPP_
#define POOL_HPP_
#include "thread.hpp"
#include "task.hpp"
class Pool
{
    public:
        static pthread_mutex_t taskQueue_lock;
        static pthread_cond_t taskQueue_cond;
        Pool();
        Pool(int num);
        virtual ~Pool();
        void initThreads();
        void assignJob(Task *_job_);
        bool loadJob(Task *&_job_);
        bool end();
    private:
        std::queue<Task*> taskQueue;
        int numOfThreads;
        std::vector<Thread*> threads;
        bool isTerminated = false;
};
#endif /* !POOL_HPP_ */
Compilation :
c++  -g -I ./includes/  -c -o sources/pool.o sources/pool.cpp
In file included from sources/pool.cpp:1:
In file included from ./includes/thread.hpp:13:
In file included from ./includes/pool.hpp:14:
./includes/task.hpp:20:24: error: unknown type name 'Thread'; did you mean 'std::thread'?
        void setThread(Thread *_thread);
                       ^~~~~~
                       std::thread
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/thread:285:24: note: 'std::thread' declared here
class _LIBCPP_TYPE_VIS thread
                       ^
In file included from sources/pool.cpp:1:
In file included from ./includes/thread.hpp:13:
In file included from ./includes/pool.hpp:14:
./includes/task.hpp:30:9: error: unknown type name 'Thread'; did you mean 'std::thread'?
        Thread *thread;
        ^~~~~~
        std::thread
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/thread:285:24: note: 'std::thread' declared here
class _LIBCPP_TYPE_VIS thread
                       ^
In file included from sources/pool.cpp:1:
In file included from ./includes/thread.hpp:13:
./includes/pool.hpp:32:28: error: expected expression
        std::vector<Thread*> threads;
                           ^
./includes/pool.hpp:32:21: error: use of undeclared identifier 'Thread'
        std::vector<Thread*> threads;
                    ^
./includes/pool.hpp:33:27: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]
        bool isTerminated = false;
                          ^
In file included from sources/pool.cpp:1:
./includes/thread.hpp:34:24: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]
        bool isWorking = false;
                       ^
2 warnings and 4 errors generated.
make: *** [sources/pool.o] Error 1
 
     
     
    