"... is not a template"和"expected initializer before '<'"错误

"... is not a template" and "expected initializer before '<'" errors

本文关键字:错误 lt before expected not is template initializer      更新时间:2023-10-16

我试图编译Nurbs++库的一部分,但遇到了一堆错误,如下所示。为什么?

nurbs_pp/matrix/source/vector.cpp:49:20: error: ‘Vector’ is not a template
nurbs_pp/matrix/source/vector.cpp:49:37: error: expected initializer before ‘<’ token

在vector.h中:

namespace PLib {
  template <class T> class Vector ;
  template<class T> class Vector : public BasicArray<T>
  {
  public:
    int rows() const //!< a reference to the size of the vector                                                                                                                                                     
      { return this->sze ;}
    Vector() : BasicArray<T>(1) {} //!< Basic constructor                                                                                                                                                           
    Vector(const int r) : BasicArray<T>(r) {}
    Vector(const Vector<T>& v) : BasicArray<T>(v) {}
    Vector(const BasicArray<T>& v) : BasicArray<T>(v)  {}
    Vector(T* ap, const int size) : BasicArray<T>(ap,size) {}
    Vector(BasicList<T>& list) : BasicArray<T>(list) {}
    virtual ~Vector() {}
    Vector<T>& operator=(const Vector<T>& v);
    Vector<T>& operator=(const BasicArray<T>& b);

矢量.cpp:

namespace PLib {
  template <class T> Vector<T>& Vector<T>::operator=(const Vector<T> &b)

问题最终出现在建筑中。有两个名为vector.h的文件,qmake不喜欢这样。