title: Restricting method call to another method
body: <p>There probably is a fairly simple and straight-forward answer for this, but for some reason I can't see it.
  I need to restrict calling methods from a class only to some methods implemented by derived classes of some interface.</p>
  
  <p>Say I have</p>
  
  <pre><code>class A{
      public:
          static void foo();
  };
  
  class myInterface{
      public:
          virtual void onlyCallFooFromHere() = 0;
  }
  
  class myImplementation : public myInterface{
      public:
          virtual void onlyCallFooFromHere()
          {
              A::foo(); //this should work
          }
          void otherFoo()
          {
              A::foo(); //i want to get a compilation error here
          }
  
  }
  </code></pre>
  
  <p>So I should be able to call <code>A::foo</code> only from the method <code>onlyCallFooFromHere()</code></p>
  
  <p>Is there a way to achieve this? I'm open to any suggestions, including changing the class design.</p>
  
  <p>EDIT:</p>
  
  <p>So... I feel there's a need to further explain the issue. I have a utility class which interacts with a database (mainly updates records) - class A.
  In my interface (which represents a basic database objects) I have the virtual function updateRecord() from which I call methods from the db utility class. I want to enforce updating the database only in the updateRecord() function of all extending classes and nowhere else. I don't believe this to be a bad design choice, even if not possible. However, if indeed not possible, I would appreciate a different solution.</p>