代码中某处有错误,但我不知道如何解决。它说“模板参数列表太少”。我不明白哪个是错误。
这是代码:
#if !defined(VECTOR_H_INCLUDED)
#define VECTOR_H_INCLUDED
#include <cstdlib> // for size_t
namespace Vec
{
class Vector_base
{
public:
explicit Vector_base() {}
};
template<typename T, int DIM>
class Vector : public Vector_base
{
typedef Vector<T,DIM> ME;
explicit Vector(T,T,T);
double dot(const ME &v) const;
T &operator [](size_t n)
{
return v[n];
}
T operator [](size_t n) const
{
return v[n];
}
private:
T v[DIM];
};
typedef Vector<double,3> Vector3;
double Vector3::dot(const ME &o) const // ----- it gives me the error here ...
{
return v[0] * o[0] + v[1] * o[1] + v[2] * o[2];
}
Vector3::Vector(double x, double y, double z) // ----- ... and here
{
v[0] = x;
v[1] = y;
v[2] = z;
}
}
#endif // VECTOR_H_INCLUDED
我必须改变什么?