S
shuisheng
Dear All,
I have a simple code, but it has some problem in cimpiling. Would you
please help me to look at it?
template<class Type, size_t N>
class Vector
{
private:
Type data[N];
public:
template<size_t i>
Type Product() const
{
return data * Product(i+1);
}
template<>
Type Product<N>() const
{
return 1;
}
}
The compilor error is that:
Error 1 error C2975: 'i' : invalid template argument for
'Vector<Type,N>:roduct', expected compile-time constant expression
What I assume is that N is a compile-time constant expression. I
appreciate your help.
Bests,
Shuisheng
I have a simple code, but it has some problem in cimpiling. Would you
please help me to look at it?
template<class Type, size_t N>
class Vector
{
private:
Type data[N];
public:
template<size_t i>
Type Product() const
{
return data * Product(i+1);
}
template<>
Type Product<N>() const
{
return 1;
}
}
The compilor error is that:
Error 1 error C2975: 'i' : invalid template argument for
'Vector<Type,N>:roduct', expected compile-time constant expression
What I assume is that N is a compile-time constant expression. I
appreciate your help.
Bests,
Shuisheng