This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
specialized constructor in specialized class
- From: Frank Winter <frank dot winter at desy dot de>
- To: gcc-help at gcc dot gnu dot org
- Date: Tue, 29 Jun 2010 17:28:55 +0200 (CEST)
- Subject: 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;
}