问一个模版特化的语法
问一个模版特化的语法
template <class T1, class T2>
class A
{
public:
void Fun();
private:
T1 t1;
T2 t2;
};
template <class T1, class T2>
void A<T1, T2>::Fun()
{
}
template <?, class T2>
void A<?, T2>::Fun<DWORD>()
{
}
template <>
void A<DWORD, T2>::Fun()
{
}
template <class T2>
class A<DWORD,T2>
{
public:
void Fun();
private:
DWORD t1;
T2 t2;
};
template <class T2>
void A<DWORD, T2>::Fun()
{
}
template <>
void A<DWORD, DWORD>::Fun()
{
std::cout<<"DWORD,DWORD fun"<<std::endl;
}
template <class T1, class T2>
class A
{
public:
void Fun();
private:
T1 t1;
T2 t2;
};
template <class T1, class T2>
void A<T1, T2>::Fun()
{
std::cout<<"normal fun"<<std::endl;
}
template <class T>
class A<DWORD, T>
{
public:
void Fun(){
std::cout<<"DWORD fun"<<std::endl;
}
private:
DWORD t1;
T t2;
};
template <>
void A<DWORD, DWORD>::Fun()
{
std::cout<<"DWORD,DWORD fun"<<std::endl;
}
int main()
{
A<DWORD,int> x;
A<int,int> y;
A<DWORD,DWORD> z;
x.Fun();
y.Fun();
z.Fun();
}
DWORD fun
normal fun
DWORD,DWORD fun