我有以下代码:
#include <iostream>
using namespace std;
template <class T> class kickingMyself {
public:
static int a;
};
template <class T> kickingMyself<T>::a = 0;
int main() {
kickingMyself<int>::a = 4;
cout << kickingMyself<int>::a << endl;
cin.get();
return 0;
}
就行:
template <class T> kickingMyself<T>::a = 0;
我收到以下错误:
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
我不知道为什么我会收到这个错误。请帮忙。
答案 0 :(得分:1)
您没有指定类型,应该是int
:
template <class T>
int kickingMyself<T>::a = 0;