3

谁能帮我理解为什么我会收到以下错误?

'vcr' 不是模板

这是模板类声明:

#include <iostream>
#include <complex>

using namespace std;

template<class T>
class vcr<complex <T> >
{
  int length;
  complex<T>* vr;
public:
  vcr(int, const complex<T>* const);
  vcr(int =0, complex<T> =0);
  vcr(const vcr&);
  ~vcr() {delete[] vr;}
  int size() const{ return length;}
  complex<T>& operator[](int i) const { return vr[i];}
  vcr& operator+=(const vcr&);
  T maxnorm() const;
  template<class S>
  friend complex<S> dot(const vcr<complex<S> >&, const vcr<complex<S> >&);
};
4

1 回答 1

3
template<class T> class vcr<complex <T> >{

...是部分模板专业化。缺少一个通用变体,它(至少)看起来像这样,并且必须在部分特化时可见:

template<class T> class vcr;

不需要为一般形式提供正文。

于 2013-07-27T07:10:25.793 回答