查看现在可用的答案,我仍然不确定答案是什么。这是我的例子
// foo.h
template <class T> class foo
{
public:
static T t;
};
template <class T> T foo<T>::t = 0;
// a.cpp
#include "foo.h"
foo<int> fa;
// b.cpp
#include "foo.h"
foo<int> fb;
// c.cpp
#include "foo.h"
foo<int> fc;
int main (int argc, char* argv[])
{
fc.t = 5;
}
这是否意味着 fa.t 和 fb.t 也是 5?如果语法不正确,请告诉我。