Redian新闻
>
Default function template arguments
avatar
Default function template arguments# Programming - 葵花宝典
n*d
1
"You can provide default arguments for template parameters in class
templates, but not function templates."
the words are from "Thinking in C++" V2. The first part is easy understood,
which is something like this
template class Stack {...}
But how to understand the 2nd part, "not funtion templates". Is it something
like this, which should be illegal according to this rule?
template T sum(T* a) {...}
avatar
k*f
2
The rule says you can have default *value* such as N=100 in template class,
but in template function you cannot do this.
avatar
n*d
3
My questionn is how to understand the "words" from the book. N=100 is about
the default parameter, but I don't think the "words" is talking about it. In
fact, you can not have (int N) as function template parameter.

,

【在 k**f 的大作中提到】
: The rule says you can have default *value* such as N=100 in template class,
: but in template function you cannot do this.

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。