65,211
社区成员
发帖
与我相关
我的任务
分享#include <iostream>
using namespace std;
template<class T>
void get(const T &a){
cout << "template invoke!\n";
}
void get(int a) {
cout << "Nomal function!\n";
}
int main() {
int a = 10;
get(a);//output : Nomal function!
//or u can invoke template explicit!
get<int>(a); //output : template invoke!
}
C++ primer plus(5TH)里说过,如果有多个原型,则编译器在选择原型是,非模板版本将优先于显示具体化和模板版本,而显示具体化将优先于模板版本生成的版本。