#include <stdio.h>
template<class T>
class TpHello
{
public:
int GetHash(){return 0;}
protected:
private:
T a;
};
template<class T>
int HashKey(T key)
{
return (int)key;
}
//Specializations of function Templates or Overloading Function templates
template<class T>
int HashKey(TpHello<Tkey)
{
return key.GetHash();
}
int main()
{
TpHello<inttpInt;
HashKey(tpInt);
return 0;
}
compile error in VC6
--------------------Configuration: template - Win32
Debug--------------------
Compiling...
template.cpp
E:\work\hellotest\template.cpp(52) : error C2667: 'HashKey' : none of 2
overload have a best conversion
E:\work\hellotest\template.cpp(52) : error C2668: 'HashKey' : ambiguous call
to overloaded function
Error executing cl.exe.
template.exe - 2 error(s), 0 warning(s)
--
= = = = = = = = = = = = = = = = = = = = = =
¡¡¡¡¡¡¡¡¡¡¡¡¡¡
zhang
----------------------------
Co.: beijing lingtu
Ad.: beijing zpart
ZIP£º 100094
Mail£ºzh**********@lingtu.com
MSN:
re********@hotmail.com
Com.£º
http://www.lingtu.com/ http://www.51ditu.com/
--------------------------