C++????????????
???????????? ???????[ 2014/7/23 11:37:05 ] ????????C++ net
?????????C++?????????????????д??????????????????????????????????????????????磬STL??sort()??????????????????????????????stack??????????????????????????????????????????????????????в??????????????????壩?????????????????????????????template specialization????
????????????????????
???????????????????????????????????е????????????????Ρ???ù????template?????????????<>????template <>??????????????????????????塣
template <typename T>
void fun(T a)
{
cout << "The main template fun(): " << a << endl;
}
template <> // ??int????????
void fun(int a)
{
cout << "Specialized template for int type: " << a << endl;
}
int main()
{
fun<char>('a');
fun<int>(10);
fun<float>(9.15);
return 0;
}
|
????????????
????The main template fun(): a
????Specialized template for int type: 10
????The main template fun(): 9.15
?????????int???????????????????????????e汾????????fun(T a)??????int????????????????汾??fun(int a)???????????????汾?????????????????????????????????????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11