C
crjjrc
I'm having trouble figuring out a problem in the following code:
template<class T, int ndims>
class NFieldBase {
public:
static const T max;
};
template<int ndims> const float NFieldBase<float, ndims>::max = 1.0f;
When compiled with g++, I get this error:
test.cpp:7: error: template definition of non-template ‘const float
NFieldBase<float, ndims>::max’
Especially confounding is that if I take out every instance of the
ndims template parameter, this code compiles just fine. Has g++
spoiled me and should this not compile in general? Or is there
something different I must be doing if I have more than one parameter?
I appreciate any help.
- Chris
template<class T, int ndims>
class NFieldBase {
public:
static const T max;
};
template<int ndims> const float NFieldBase<float, ndims>::max = 1.0f;
When compiled with g++, I get this error:
test.cpp:7: error: template definition of non-template ‘const float
NFieldBase<float, ndims>::max’
Especially confounding is that if I take out every instance of the
ndims template parameter, this code compiles just fine. Has g++
spoiled me and should this not compile in general? Or is there
something different I must be doing if I have more than one parameter?
I appreciate any help.
- Chris