title: Can a private function of a class be called from a local function?
body: <p>Simplification of the code to express the concept:</p>
  
  <pre><code>class classA
  {
  
  public:
  
  private:
     int a;
     seta(int x);
  };
  
  //local prototype
  void somefunction();
  
  int main()
  {
    classA object; //create an object of the class
  
    somefunction(object);
    return 0;
  }
  
  void somefunction(classA &amp;object)
  {
  
    object.seta(5);    
  }
  </code></pre>
  
  <p>}</p>
  
  <p>If I move <code>seta()</code> to the public section of the class there is no error and it executes.</p>
  
  <p>However, if I move <code>seta()</code> to the private section, I get the following error:  </p>
  
  <blockquote>
    <p>error C2248:
     '<code>anonymous-namespace'::classA::seta' : cannot access
    private member declared in class '</code>anonymous-namespace'::classA'</p>
  </blockquote>
  
  <p>If the function is private and only this class is calling it, why is there an issue?</p>
  
  <p><strong>EDIT</strong> I am passing the object from main to the local function  </p>