我不确定为什么我的代码出错。我收到以下错误:第22行错误C2910:'Spunky :: {ctor}':无法显式专用,第26行错误C2514:'Spunky':类没有构造函数。这是我的代码:
#include <iostream>
#include <string>
using namespace std;
template <typename T>
class Spunky{
public:
Spunky(T x){
cout << x << " is not a character!" << endl;
}
};
template<>
class Spunky<char>{
public:
Spunky(char x);
};
template<>
Spunky<char>::Spunky(char x){
cout << x << " is a character!" << endl;
}
int main()
{
Spunky s(1);
Spunky <char>d('a');
system("pause");
return 0;
}