title: Accessing static variable from a friend function
body: <pre><code>class Base
  {
  private:
      static int num; 
  public:
      friend void setnum(Base obj); 
  };
  
  void setnum(Base obj)
  {
      obj.num=4;  /* Error */
  }
  </code></pre>
  
  <p>A friend function is supposed to have access to all the private data of a class. what am i missing here? I cant seem to access the the static variable from the friend function. </p>
  
  <blockquote>
    <p>Error from codepad-->  In function
    <code>setnum(Base)': undefined reference to
    </code>Base::num'</p>
    
    <p>Error from visual studio--> error LNK2001:
    unresolved external symbol "private:
    static int Base::num"</p>
  </blockquote>