gpt4 book ai didi

c++ - 功能级别的部分模板类特化

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:29:41 26 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Template partial specialization with multiple template argument error

是否可以将模板类专门化为功能级别?

我会给你和我想要实现的例子,但我得到了编译错误:

template<typename T1, typename T2>
class C
{
public:
void f();
};

template<typename T1, typename T2>
void C<T1, T2>::f()
{
}

template<typename T1, int>
void C<T1, int>::f()
{
}

错误:

template argument list following class template name must list parameters in the order used in template parameter list
'void C<T1,T2>::f(void)' : function template has already been defined
'C<T1,T2>': template parameter 'T2' is incompatible with the declaration

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