2012-08-30 195 views
0

我有下面的类结构:静态成员

class A { 
    template<typename T> static void f(const T& input) { 
    //do something with X and input 
    } 
    static ostringstream x; 
} 

然后在主我做的:

... 
int n = 5; 
A::f(n); 
... 

编译没有问题,但我得到一个链接错误A :: x是无法找到的符号。有没有人遇到过这个错误?

谢谢!

回答

2

是的,你没有定义x

// A.cpp 
std::ostringstream A::x; 
+0

谢谢!这解决了它。 – user1094206

+0

@ user1094206不客气 – justin