Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Template specialization: Is not a Template

Can anyone help me understand why I am getting the following error?

'vcr’ is not a template

Here is the template class declaration:

#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> >&);
};
like image 454
Stephen Jacob Avatar asked Sep 03 '25 09:09

Stephen Jacob


1 Answers

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

... is a partial template specialization. There is a missing general variant, which would (at least) look like this, and which must be visible at the point of the partial specialization:

template<class T> class vcr;

You do not need to provide a body for the general form.

like image 66
Sebastian Mach Avatar answered Sep 04 '25 23:09

Sebastian Mach