title: Undefined reference to static variable c++
body: <p>Hi i am getting undefined reference error in the following code:</p>
  
  <pre><code>class Helloworld{
    public:
       static int x;
       void foo();
  };
  void Helloworld::foo(){
       Helloworld::x = 10;
  };
  </code></pre>
  
  <p>I don't want a <code>static</code> <code>foo()</code> function. How can I access <code>static</code> variable of a class in non-<code>static</code> method of a class?</p>