简体   繁体   English

模板参数数量错误

[英]Wrong number of template arguments error

I'm new to templates and trying to use my functions that are out of the class to adapt to the generic programming. 我是模板的新手,尝试使用类之外的函数来适应通用编程。 But wenn I do this: 但是我这样做:

template<int C, int D>
class A{
    ...
}

float function(number<int C, int D> value);

it leads to following error: 它导致以下错误:

Error: wrong number of template arguments (1, should be 2)
float function(number<int C, int D> value);
                               ^

Am I missing something here? 我在这里想念什么吗?

You need to define template arguments on the function and forward them to the type: 您需要在函数上定义模板参数,并将其转发给类型:

template<int C, int D>
float function(number<C, D> value);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM