#include<iostream>
using namespace std;
// define the general compare template
template <class T>
int compare(const T& t1, const T& t2) {
cout<< "Common_T"<<endl;
return 0;
}
template<>
int compare<const char*>( const char * const& s1,
const char * const& s2)
{
cout<< "Special_T"<<endl;
return 0;
}
typedef const char char6[6];
template<>
int compare<char6>(const char6& s1,const char6& s2)
{
cout << "Special_Char6_T" << endl;
return 0;
}
int main() {
int i = compare("hello" , "world");
}
结果是:
Common_T
我的问题是:为什么不输出“Special_Char6_T”???