这是我的代码:
template<typename T1, typename T2> class MyClass
{
public:
template<int num> static int DoSomething();
};
template<typename T1, typename T2> template<int num> int MyClass<T1, T2>::DoSomething()
{
cout << "This is the common method" << endl;
cout << "sizeof(T1) = " << sizeof(T1) << endl;
cout << "sizeof(T2) = " << sizeof(T2) << endl;
return num;
}
Run Code Online (Sandbox Code Playgroud)
它运作良好.但是当我尝试添加这个
template<typename T1, typename T2> template<> int MyClass<T1, T2>::DoSomething<0>()
{
cout << "This is ZERO!!!" << endl;
cout << "sizeof(T1) = " << sizeof(T1) << …Run Code Online (Sandbox Code Playgroud)