I have a code like this. When run, it's return fault: undefined reference to A::x. How can I fix this?
#include <iostream> using namespace std; class A { private: static int x; public: A(){ } A(int t) { x = t; } static void f() { cout<< A::x; } int f2() { return x; } }; int main() { A::f(); A a; a.f2(); }