gpt4 book ai didi

c++ - 模板特化 : Is not a Template

转载 作者:太空狗 更新时间:2023-10-29 21:23:36 24 4
gpt4 key购买 nike

谁能帮我理解为什么会出现以下错误?

'vcr’ is not a template

这是模板类声明:

#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> >&);
};

最佳答案

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

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

template<class T> class vcr;

不需要为通用表单提供正文。

关于c++ - 模板特化 : Is not a Template,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17895216/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com