#include <iostream>
#include <string>
using std::cout;
using std::endl;
template <typename T> T Max(T a, T b)
{
if (a>=b)
{
return a;
}
return b;
}
char* Max(char* a, char* b)
{
if (NULL==a || NULL==b)
{
if (NULL!=a)
{
return a;
}
if (NULL!=b)
{
return b;
}
return NULL;
}
int cmp_str =strcmp(a, b);
if (cmp_str>=0)
{
return a;
}
return b;
}
int main(int argc, char* argv[])
{
cout<<Max("a","b")<<endl;
return 0;
}
on vc6.0 , can carry out function char* Max(char* a, char* b),
but on vc2005, template T Max(T a, T b) execute.
I change it, function const char* Max(cosnt char* a, const char* b),
vc2005, can carry out.
I want to konw why two VC++, have different about const char * and char * for template.