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 に答える