리눅스에서 상속관련 질문입니다.
전체적인 내용을 요약을 한다면은
IWorkerPool 의 protected로
int _total_thrcount;
Type_Interface_Worker **_threads;
선언을 하여주었습니다.
후에 WorkerPool 에서 IWorkerPool을 상속을 받습니다.
그렇게 하여서 WorkerPool.inl파일에서 상속을 받은 _total_thrcount를 사용을하는데
was not declared in this scope 에러가 나타납니다..
질문) 제 생각으로는 상속에 문제사항이 없다고 생각합니다 하지만 에러 메시지가 나타나서 질문올립니다.
꼭 답이아니더라도 어떠한형식으로 구글에서 검색을 해야 하는지 등이라도 알려주시면 감사하겠습니다.
구글링을 해보았는데 해당하는 문제점에 대해서 찾을수가 없었습니다.
또한 밑에쪽에서 expected class-name before ‘class’ 오류 메시지가 나타나는데 저부분은 ACE 프레임웤에서 에러나는 부분입니다.
ACE는 정상적으로 설정하여서 설치하였습니다. 저쪽에서 오류가 날수있는 상황이 아니라고 믿고있습니다.
저 오류에 대해서도 아신다면은 부탁드립니다...
질문하는 부분들은 찾아본후에 찾을수 없고 방향조차 찾기가 어렵습니다 잘부탁 드립니다.
IWorkerPool 헤더 파일입니다.
namespace HEMS_CENTER { template<class Type_Interface_Worker, class Type_task> class IWorkerPool { public: IWorkerPool() { } IWorkerPool(int threadCount) { } virtual ~IWorkerPool() { if (_threads) { for (int i = 0; i < _total_thrcount; i++) { _threads[i]->stop(); delete _threads[i]; } } delete [] _threads; } virtual int runAll() { for (int i = 0; i < _total_thrcount; i++) { _threads[i]->activate(); } return 0; } virtual int distribute_task(Type_task *task)=0; protected: int _total_thrcount; Type_Interface_Worker **_threads; // worker array; }; } #endif
여기가 상속받는 클래스 입니다.. IWorkerPool의 내용을 상속받습니다.
namespace HEMS_CENTER { template<class Type_worker, class Type_quedata> class WorkerPool<Type_worker , Type_quedata> : public IWorkerPool<IHemsWorker<Type_quedata>, Type_quedata> { public: WorkerPool(); WorkerPool(int threadCount); virtual ~WorkerPool(); virtual int runAll(); virtual int distribute_task(Type_quedata *task); private: unsigned int _threadindex; }; } #include "WorkerPool.inl"
#include "WorkerPool.h" namespace HEMS_CENTER { template<class Type_worker, class Type_quedata> WorkerPool<Type_worker, Type_quedata>::WorkerPool() : _threadindex(0) { _threads = new IHemsWorker<Type_quedata>*[10]; for (int i = 0; i < 10; i++) { _threads[i] = new Type_worker(); } _total_thrcount = 10; } template<class Type_worker, class Type_quedata> WorkerPool<Type_worker, Type_quedata>::WorkerPool(int threadCount) : _threadindex(0) { _threads = new IHemsWorker<Type_quedata>*[threadCount]; for (int i = 0; i < threadCount; i++) { _threads[i] = new Type_worker(); } _total_thrcount = threadCount; }
에러메시지 부분입니다...
../libhems/WorkerPool.h:8:8: error: ‘WorkerPool’ is not a template In file included from ../libhems/WorkerPool.h:20:0, from ../libhems/WorkerpoolMgr.h:11, from HEMSCNTR.cpp:11: ../libhems/WorkerPool.inl: In constructor ‘HEMS_CENTER::WorkerPool<Type_worker, Type_quedata>::WorkerPool()’: ../libhems/WorkerPool.inl:6:3: error: ‘_threads’ was not declared in this scope ../libhems/WorkerPool.inl:10:3: error: ‘_total_thrcount’ was not declared in this scope ../libhems/WorkerPool.inl: In constructor ‘HEMS_CENTER::WorkerPool<Type_worker, Type_quedata>::WorkerPool(int)’: ../libhems/WorkerPool.inl:15:3: error: ‘_threads’ was not declared in this scope ../libhems/WorkerPool.inl:19:3: error: ‘_total_thrcount’ was not declared in this scope ../libhems/WorkerPool.inl: In member function ‘virtual int HEMS_CENTER::WorkerPool<Type_worker, Type_quedata>::runAll()’: ../libhems/WorkerPool.inl:36:10: error: ‘template<class Type_Interface_Worker, class Type_task> class HEMS_CENTER::IWorkerPool’ used without template parameters ../libhems/WorkerPool.inl: In member function ‘virtual int HEMS_CENTER::WorkerPool<Type_worker, Type_quedata>::distribute_task(Type_quedata*)’: ../libhems/WorkerPool.inl:42:36: error: ‘_total_thrcount’ was not declared in this scope In file included from /usr/local/include/ace/Timer_Queue_T.h:26:0, from /usr/local/include/ace/Timer_Queue.h:26, from ScheduleUpdate.h:4, from HEMSCNTR.cpp:14: /usr/local/include/ace/Abstract_Timer_Queue.h: At global scope: /usr/local/include/ace/Abstract_Timer_Queue.h:27:1: error: expected class-name before ‘class’
댓글 달기