This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

specialized constructor in specialized class


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;
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]