title: Design pattern to ensure that a method A is called before method B
body: <p>I have a sample(incomplete) class like  </p>
  
  <pre><code>class ABC{   
  public:      
      void login();      
      void query_users();       
      //other methods  
  private:      
      //member data
  }
  </code></pre>
  
  <p>This class should be used in a way that login needs to be called first and then only other methods like query_users, etc., can be called. Login sets some private member data for the other methods to use. Is there any simpler way to achieve this other than calling a function that checks if the member data is set at the start of every other method in the class? </p>