Problems with templates

llewelly@dbritsch.dsl.xmission.com llewelly@dbritsch.dsl.xmission.com
Tue Jun 13 00:43:00 GMT 2000


On Tue, 13 Jun 2000, Hubert Felber wrote:

> Hi,
> 
> Can anybody please help me?

> 
> I have problems compiling a nested template class, I get the error message:
> 
> Wrapper.h:10: declaration of 'class T'
> Wrapper.h:6:   shadows template parm 'class T'
> 
> I am using g++ 2.95.2. Using another compiler on a non linux platform, this template compiles fine.
> 
> How can I change my code that it compiles fine with gcc 2.95.2 ?
> 
> Here is the snippet:
> 
> 
> template <class T> class CWrapper  // line 6
> {
> 
>   template <class T> class CCounted         //line 10
                   ^^
Change the name of  this template parameter.

>   {
>     friend class CWrapper<T>;
>   private:
> 
>     inline CCounted(T* pT) : Count(0), my_pT(pT) 
>     {...  } 
> 
>     inline ~CCounted()
>     {...}
> 
>     inline unsigned AddRef()
>     { }
>     inline unsigned Release() 
>     {}
> 
> public:
>     T* const my_pT;
>   };
> public:
> 
>   inline CWrapper(): m_pCounted(0) {}
> 
>   inline CWrapper(T* pT)
>   {
>     m_pCounted = new CCounted<T>(pT);
>     m_pCounted->AddRef();
>   }
> 
> 
> .....
> 
> snipped the rest
> ....
> private:
> 
> 
> ///////////////////////////////////////////////////////////////////////////////
>   CCounted<T>* m_pCounted;
> 
> };
> 
> 
> 



More information about the Gcc-help mailing list