Deriving a template class? Please help.
-
Hi, I am running into a problem with deriving an atl class. I am using VS.Net and have run the wizard to create an non-attributed atl service. I want it to be an interactive service so I decided that I would need to derive the CAtlServiceModuleT class and add m_status.dwServiceType |= SERVICE_INTERACTIVE_PROCESS; to make the service an interactive process. This is the class that I created in a header file I call ATLINTERACTIVEPROCESS.H
#pragma once #include <atlbase.h> #ifndef _ATL_NO_SERVICE template <class T, UINT nServiceNameID> class ATL_NO_VTABLE CAtlInteractiveServiceModuleT : public CAtlServiceModuleT<T, nServiceNameID> { public : CAtlInteractiveServiceModuleT() throw() { m_status.dwServiceType |= SERVICE_INTERACTIVE_PROCESS; } }; #endif
When I compile this I get the following errors ATLINTERACTIVESERVICE.h(7) : error C2504: 'CAtlServiceModuleT' : base class undefined ATLINTERACTIVESERVICE.h(15) : see reference to class template instantiation 'CAtlInteractiveServiceModuleT' being compiled ATLINTERACTIVESERVICE.h(7) : error C2143: syntax error : missing ',' before '<' I would assume that including <atlbase.h> would "define" the base class. If I take the code and drop it in the atlbase.h header file just under CAtlServiceModuleT<> everything compiles fine. Unfortunately I don't want to keep this code in the atlbase.h file because it could be changed by microsoft and my collegues would have to have a "special" version of atlbase.h to compile this service. Does anyone have any idea what I am doing wrong? Can derived template classes exist in other header files than their base classes? Are there defines that I am missing? As a side note is there a way to debug the compile pass? Please help!!:) Cheers, Clint
-
Hi, I am running into a problem with deriving an atl class. I am using VS.Net and have run the wizard to create an non-attributed atl service. I want it to be an interactive service so I decided that I would need to derive the CAtlServiceModuleT class and add m_status.dwServiceType |= SERVICE_INTERACTIVE_PROCESS; to make the service an interactive process. This is the class that I created in a header file I call ATLINTERACTIVEPROCESS.H
#pragma once #include <atlbase.h> #ifndef _ATL_NO_SERVICE template <class T, UINT nServiceNameID> class ATL_NO_VTABLE CAtlInteractiveServiceModuleT : public CAtlServiceModuleT<T, nServiceNameID> { public : CAtlInteractiveServiceModuleT() throw() { m_status.dwServiceType |= SERVICE_INTERACTIVE_PROCESS; } }; #endif
When I compile this I get the following errors ATLINTERACTIVESERVICE.h(7) : error C2504: 'CAtlServiceModuleT' : base class undefined ATLINTERACTIVESERVICE.h(15) : see reference to class template instantiation 'CAtlInteractiveServiceModuleT' being compiled ATLINTERACTIVESERVICE.h(7) : error C2143: syntax error : missing ',' before '<' I would assume that including <atlbase.h> would "define" the base class. If I take the code and drop it in the atlbase.h header file just under CAtlServiceModuleT<> everything compiles fine. Unfortunately I don't want to keep this code in the atlbase.h file because it could be changed by microsoft and my collegues would have to have a "special" version of atlbase.h to compile this service. Does anyone have any idea what I am doing wrong? Can derived template classes exist in other header files than their base classes? Are there defines that I am missing? As a side note is there a way to debug the compile pass? Please help!!:) Cheers, Clint
The 'CAtlServiceModuleT' class is hidden by the ATL namespace. Cheers, Clint