-2
我的代码;错误:太多模板参数列表
template<typename T, int N>
class ngon{
point<T> vertices[N];
...
template<typename O> ngon<T,N>& operator=(const ngon<O,N> otyp);
// O stands for other, as in other type
...
};
...
template<typename T, int N> typename<typename O>
ngon<T,N>& operator=(const ngon<O,N> otyp){
for (int i = 0; i < N; i++)
vertices[i] = point<T>(otyp.vertices[i]);
return this;
}
给出错误;
.\Libraries/.\Geometry\Polygon_D2.hpp:103:11: error: too many template-parameter-lists
ngon<T,N>& operator=(const ngon<O,N> otyp){
我做错了什么?模板是完全正确的。
这是什么附加'typename'在'template typename '...? –
vsoftco
它自动化类型转换 – user4578093
我的意思是语法。它看起来像一个错字,你在模板decl之外有一个'typename',并且没有依赖类型,所以不需要'typename'。 –
vsoftco