specialized constructor in specialized class

Frank Winter frank.winter@desy.de
Tue Jun 29 16:33:00 GMT 2010


Dear list,

I try to specialize a copy constructor in a specialized class. I 
keep getting:

"explicit specialization in non-namespace scope class RComplex<double>"

from the compiler. I use GNU g++
gcc version 4.3.4

How can the specialized constructor be defined?

Frank





template<class T> class RComplex
{
public:
   RComplex() {}
   ~RComplex() {}
private:
   T re;
   T im;
};


template<>
class RComplex<double>
{
public:
   RComplex() {}
   ~RComplex() {}

   template<class T>
   RComplex(T arg)
   {
   }

   template<>
   RComplex(int arg)
   {
   }

private:
   double F[2];
};


int main()
{
   int i=1;
   RComplex<double> z(i);

   return 0;
}



More information about the Gcc-help mailing list