template void f(T a){ cout << "aaaaaaa"; }
template <> void f(int & a){ cout << "fffffffffff"; }
int b;f(b);
为什么输出aaaaaaa,不是应该输出fffffffffff吗,看书上说具体化优先于模板函数的
求知道的大神指点下啦,万分感谢
template void f(T a){ cout << "aaaaaaa"; }
template <> void f(int & a){ cout << "fffffffffff"; }
int b;f(b);
为什么输出aaaaaaa,不是应该输出fffffffffff吗,看书上说具体化优先于模板函数的
求知道的大神指点下啦,万分感谢
#include <iostream>
using namespace std;
template <typename T>void f(T a){ cout << "aaaaaaa"; }
void f(int & a){ cout << "fffffffffff"; }
int main()
{
int b;
f(b);
}
http://codepad.org/iyORv2CE
在线运行的结果
输出的是fffffffffff